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

-----------------------------------
Traps for Escape being pressed.
-----------------------------------

The ON ESCAPE command sets a trap for an Esc (Escape) key press.  When
the Esc key is pressed, the trap is triggered and the specified command
is executed.

An ON ESCAPE routine remains in effect until another ON ESCAPE routine
is encountered.  The new ON ESCAPE routine supersedes the old one.  An
ON ESCAPE command may be deactivated by issuing ON ESCAPE without
including the <command>.

After the ON ESCAPE routine is complete, program execution resumes on
the line immediately following the line on which the ON ESCAPE 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.

If both an ON ESCAPE and an ON KEY routine are in effect and the Esc key
is pressed, the ON ESCAPE routine is executed, taking precedence over
the ON KEY routine.

WARNING -- An ON ESCAPE routine will not be executed if SET ESCAPE is
OFF.

+---------------------------------+
|         Program Example         |
+---------------------------------+
This example prints records from the CUSTOMER database as long as Escape
is not pressed.  If Escape is pressed, the PROCEDURE named STOP is
executed.  STOP double checks to be sure that you really wish to cancel
printing, and if so exits from the printing routine.

SET ESCAPE ON
SET TALK OFF
USE customer
CLEAR
SET DEVICE TO PRINTER
ON ESCAPE DO stop
STORE .T. TO mprint
DO WHILE NOT EOF() AND mprint
   @ PROW() + 1,10 SAY 'Company: ' + company
   @ PROW() + 1,10 SAY 'Address: ' + address1
   @ PROW() + 1,1 SAY ' '
   SKIP
ENDDO
SET DEVICE TO SCREEN

PROCEDURE stop
SET DEVICE TO SCREEN
STORE ' ' TO mcheck
@ 10,10 SAY 'Cancel Printing (Y/N) ? ' GET mcheck ;
PICTURE '!' VALID mcheck $ 'YN'
READ
@ 10,10 TO 10,79 CLEAR
IF mcheck = 'N'
   SET DEVICE TO PRINTER
   RETRY
ENDIF
EJECT
STORE .F. TO mprint
RETURN

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

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

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

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