SET ESCAPE OFF Does Not Disable the ESC Key

Last reviewed: April 29, 1996
Article ID: Q98444
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5x, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x

SUMMARY

The command SET ESCAPE OFF does not disable the ESC key.

MORE INFORMATION

SET ESCAPE OFF keeps the user from interrupting executing lines of code by pressing the ESC key; however, SET ESCAPE OFF will not prevent a user from escaping from an active READ. The reason is that a READ, unlike most commands, creates a wait state; that is, it begins a period of waiting (often for input) that continues. Since the READ instruction may not finish for some time, keyboard input, including the ESC key, is interpreted by the READ, not by SET ESCAPE OFF, which cannot trap the ESC key in the middle of an executing instruction; therefore, the READ reacts to the ESC key (and often this means a screen with active GETs is terminated).

If the ESC key is pressed while non-wait-state lines of code are executing, the ESC key will be buffered temporarily until the current instruction finishes, and then the ESC key will be trapped as expected, permitting continued program execution.

The SET ESCAPE command determines whether FoxPro will interrupt executing code when the ESC key is pressed. If SET ESCAPE is ON and code is being executed, FoxPro will display the "*** INTERRUPTED ***" error message. If SET ESCAPE is OFF, the program will not be halted. If a READ is in effect and the program is sitting idle at that READ when the ESC key is pressed, the READ will be terminated regardless of the setting of ESCAPE and no message will appear.

To disable the ESC key, issue the following command:

   ON KEY LABEL ESC *

This command completely disables the ESC key until ON KEY LABEL ESC is issued. To disable any other key, substitute the appropriate key name for ESC in the above command.

NOTE: If you have saved the environment with the screen or are opening a view, the SET ESCAPE OFF and ON KEY LABEL ESC * commands may not work as expected if the environment or view had different settings for these commands. To work around this, you can explicitly enter these commands in the Command window before saving the environment or view. An alternative workaround regarding the environment is to not save the environment with the screen; instead use code to explicitly create the environment.


Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a
2.50b 2.60
KBCategory: kbprg
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.