Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ON ESCAPE Command
Collapse the table of content
Expand the table of content

ON ESCAPE Command

Visual Studio .NET 2003

Specifies a command that executes when you press the ESC key during program or command execution.

ON ESCAPE   [Command]

Parameters

Command
Specifies the Visual FoxPro command to execute. After the command executes, program execution resumes on the line immediately following the program line that was executing when you pressed ESC. However, if a procedure specified with ON ESCAPE includes RETRY, the program line that was executing when you pressed ESC executes again.

Remarks

Typically, ON ESCAPE uses DO to execute a procedure.

If both ON ESCAPE and ON KEY are in effect and you press ESC, Visual FoxPro executes the command specified with ON ESCAPE.

Use ON ESCAPE without a command to cause no command to execute when ESC is pressed (the default).

Note   Visual FoxPro doesn't execute an ON ESCAPE routine if SET ESCAPE is OFF.

Example

The following example sets up an infinite loop but defines an ON ESCAPE routine to exit it.

SET ESCAPE ON
ON ESCAPE DO stopit
WAIT WINDOW 'Press ESC to stop loop' NOWAIT
glMoreLoop = .T.

DO WHILE glMoreLoop
ENDDO
RETURN

PROCEDURE stopit
glMoreLoop = .F.
RETURN

See Also

INKEY( ) | ON ESCAPE Command | DO Command

Show:
© 2015 Microsoft