[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|             ON KEY              |
+---------------------------------+
ON KEY [<command>]

-----------------------------------
Traps for any key being pressed during program execution.
-----------------------------------

The ON KEY command sets a trap for any key being pressed.  When a key is
pressed, the trap is triggered and the <command> is executed.

Only one ON KEY routine may be active at a time.  If multiple ON KEY
routines have been executed, only the most recently executed routine
remains in effect.  If ON ESCAPE and ON KEY routines are in effect and
ESCAPE is SET ON, pressing Esc triggers the ON ESCAPE routine, not the
ON KEY routine.  If ESCAPE is SET OFF and Esc is pressed, the ON KEY
routine will be executed.

After the ON KEY routine is completed, program execution resumes on the
line immediately following the line on which the branch occurred.
However, if the <command> is DO <program> and the <program> is exited
via a RETRY statement, execution resumes on the same line on which the
branch occurred.

+---------------------------------+
|         Program Example         |
+---------------------------------+
In this example, records from CUSTOMER database are displayed on the
screen.  If any key is pressed, ON KEY trap is triggered and PROCEDURE
called V_WAIT is called.  V_WAIT pauses output with WAIT.

SET TALK OFF
USE customer
CLEAR
ON KEY DO v_wait
DO WHILE NOT EOF()
   ? 'Company: ' + company
   ? 'Address: ' + address1
   ?
   SKIP
ENDDO

PROCEDURE v_wait
STORE INKEY() TO HOLD
WAIT
RETURN

-----------------------------------

See Also:  INKEY(), LASTKEY(), ON KEY =, ON KEY LABEL, ON(), READKEY(),
RETRY, RETURN, SET ESCAPE

-----------------------------------

See Also: INKEY() LASTKEY() ON KEY = ON KEY LABEL ON() READKEY()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson