Changes the default behavior of the Esc key so that it executes a specified command instead of interrupting command or program execution.

Syntax

ON ESCAPE [<command>]

<command>

The command to execute when the following conditions are in effect:

SET ESCAPE is ON

The user presses Esc during command or program execution

The <command> may be any valid dBL command, including a DO command to execute a program file, a function call that executes a program or function loaded in memory, or a codeblock.

ON ESCAPE without a <command> option disables any previous ON ESCAPE <command>.

Description

The primary purpose of the Esc key is to interrupt command or program execution. This behavior may be changed with ON ESCAPE; either way it occurs only when SET ESCAPE is ON (its default setting).

When no ON ESCAPE <command> is in effect, pressing Esc interrupts program execution and displays the dBASE Plus Program Interrupted dialog box. If ON ESCAPE <command> is in effect, pressing Esc during program execution executes the specified command instead and then continues program execution.

While executing a command (like CALCULATE) from the Command window, pressing Esc with ON ESCAPE <command> in effect executes <command> and then terminates the command, returning control to the Command window. If no ON ESCAPE <command> is in effect, pressing Esc during a command from the Command window simply terminates that command and displays a message in the status bar.

Note that user interface elements such as menus, forms, and dialog boxes handle Esc differently, usually closing or dismissing that UI element. (For forms, this behavior is controlled by its escExit property.) In those cases, ON ESCAPE and SET ESCAPE have no effect. In fact, with the exception of dialog boxes and forms opened with ReadModal( ), because of the event-driven nature of dBASE Plus there is no program executing when you use a menu or type into a form, so there is nothing to interrupt.

Use ON KEY to specify a new meaning or mapping for Esc or any other key. If both ON KEY and ON ESCAPE are in effect, ON KEY takes precedence when Esc is pressed. In other words, while ON ESCAPE changes the Escape behavior, ON KEY changes the meaning of the Esc key, so that pressing it no longer causes that Escape behavior. While the Escape behavior affects only programs or commands that are executing, ON KEY works at all times.

If you issue ON ESCAPE<command> in a program, you should disable the current ON ESCAPE condition by issuing ON ESCAPE without a <command> option before the program ends. Otherwise, the ON ESCAPE condition remains in effect for any subsequent commands and programs you issue and run until you exit dBASE Plus.