CHRSAW( ) Function

Determines whether or not a character is present in the keyboard buffer.

CHRSAW([nSeconds])

Return Values

Logical

Parameters

  • nSeconds
    Specifies the time in seconds that CHRSAW( ) waits before checking the keyboard buffer. The keyboard buffer is checked immediately if you omit nSeconds.

    Including nSeconds lets you use CHRSAW( ) for a variety of timed activities. For example, your program can close an application if a key hasn't been pressed for a specific number of seconds.

Remarks

CHRSAW( ) returns True (.T.) if a character is present in the keyboard buffer, and False (.F.) if not. CHRSAW( ) doesn't affect the keyboard buffer contents.

Example

In the following example, the system displays a window containing input fields created with @ ... GET commands, and waits 5 seconds for keyboard input. If a key isn't pressed in this time period, CHRSAW( ) returns False (.F.) and the program terminates.

SET TALK OFF
DEFINE WINDOW wEnter FROM 7,10 to 13,70 PANEL
ACTIVATE WINDOW wEnter
@ 1,3 SAY 'Customer: '   GET gcCustomer  DEFAULT SPACE(40)
@ 3,3 SAY 'Address:  '   GET gcAddress  DEFAULT SPACE(40)
WAIT WINDOW 'Waiting for input' NOWAIT
IF NOT CHRSAW(5)   
   DEACTIVATE WINDOW wEnter
   CLEAR GETS
ELSE
   READ
   DEACTIVATE WINDOW wEnter
ENDIF
RELEASE WINDOW wEnter
WAIT 
CLEAR

See Also

INKEY( ) | KEYBOARD | READKEY( )