How to Undo ON KEY LABEL ENTER Command After Error

ID: Q113922

The information in this article applies to:

SUMMARY

Under certain circumstances, you may want to redefine the ENTER key so that it performs an action, such as executing a procedure. However, if an error occurs during development before the ENTER key is returned to its original state, no commands can be entered in the Command window, and the statement following the ON KEY LABEL ENTER command will attempt to execute instead.

MORE INFORMATION

Issuing the command "ON KEY LABEL ENTER <function or command>" prior to the point at which that action is desired will cause that statement to be executed when the ENTER key is pressed. To return the ENTER key to its normal functionality, the command "ON KEY LABEL ENTER" (with nothing following it) should be the first line of code in the procedure or function (or the second line if there is a PARAMETER statement).

However, errors may occur before the line returning the ENTER key to the default is executed, preventing the ENTER key from terminating commands in the Command window. The following methods will allow you to restore the normal functionality of the ENTER key.

After returning to the Command window from the error condition, do the following:

Method 1

1. In FoxPro for MS-DOS, choose Macros from the System menu. In FoxPro for

   Windows, choose Macros from the Program menu.

2. Select an unused default macro, such as F3.

4. Choose the Edit button.

5. Type the following:

      ON KEY LABEL enter{LITERAL+ENTER}

6. Choose OK twice to close the Edit and Macros windows.

7. Press the macro key you just assigned.

NOTE: The above method will not work if the macro key you chose is already assigned an action by an ON KEY LABEL command. For example, if the command ON KEY LABEL F3 WAIT WIND TIME() is issued at the beginning of a FoxPro session and is never released, the macro editor will still show the default of "LIST{ENTER}" for F3. Even though the macro is redefined, the ON KEY LABEL trap will have precedence, and the current time will be displayed instead.

Method 2

1. From the File menu, choose New. In the New File dialog box, choose

   Program and then choose New.

2. In the UNTITLED.PRG window, type the following command:

      ON KEY LABEL ENTER

3. Press CTRL+O to execute the program and choose Yes to save changes.
   Type a name for the program and then choose Save.

The ENTER key is now reset.

Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b 2.60 hung hang return ignored KBCategory: kbprg KBSubcategory: FxprgGeneral

Last Reviewed: June 27, 1995