Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- NetLib for Clipper, Version 6.0 - n_onnokey( [ <nseconds> [, <cprocedure>|<nkey> ] ] ) http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
N_ONNOKEY( [ <nSeconds> [, <cProcedure>|<nKey> ] ] )


Parameters

<nSeconds>
Interval to wait for keyboard activity. If no key is pressed, a 
procedure is called.

<cProcedure>
Name of the procedure to execute.

<nKey>
ASCII value of a key to stuff onto the keyboard.


Returns

The number of seconds remaining until the procedure will be called.


Description

Sets a procedure to call if there is no keyboard activity within a 
specified interval. Trapping for this non-event is active only 
while in a wait state such as READ or ACCEPT.

N_ONNOKEY(<nSeconds>) with no second parameter alters the time interval 
without changing the procedure. Deactivate the event trap by calling 
N_ONNOKEY(0). You should disable it as soon as you no longer need it.


Example

// Blank the screen if no key is pressed within 5 minutes
// while in a wait state. Restore the screen when any
// key is pressed.
N_ONNOKEY(300, 'Blanker')
.
.
.
PROCEDURE Blanker
   STATIC cScreen
   STATIC lOn := .F. // Initial value assigned once.
   IF lOn
      // Called by N_ONANYKEY('Blanker')
      N_ONANYKEY("")            // Disable event trap.
      INKEY()                   // Pull key from buffer.
      RESTORE SCREEN FROM cScreen
      lOn = .F.                 // Set flag Off.
      N_ONNOKEY(300, 'Blanker') // Reset no-key trap.
   ELSE
      // Called by N_ONNOKEY('Blanker')
      N_ONNOKEY(0)              // Disable event trap.
      SAVE SCREEN TO cScreen
      CLS
      lOn = .T.                 // Set flag On.
      N_ONANYKEY('Blanker')     // Look for a keypress.
   ENDIF
RETURN



See Also: N_ONANYKEY()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson