Microsoft KB Archive/89574

{| = ON Function Returns Command Assigned to Handle Event =
 * width="100%"|

ID: Q89574

The information in this article applies to:


 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
 * Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY
The ON function returns the command that is assigned to handle the specified class of events. The ON ERROR, ON ESCAPE, ON KEY LABEL, ON PAGE, and ON READERROR commands specify the command that handles the corresponding class of events. The ON function is new in FoxPro version 2.0 for MS-DOS.

MORE INFORMATION
The syntax for the ON function is as follows

ON( [, ]) where  specifies one of the event classes. Valid values for  include the following: Command             ---            ---

ON ERROR           ERROR ON ESCAPE          ESCAPE ON KEY             KEY ON KEY LABEL       KEY ON PAGE            PAGE ON READERROR       READERROR If the ON function is used to determine which command is assigned to a key through an ON KEY or ON KEY LABEL command, specify the desired key in the  parameter. The following are examples of using the ON function:

X=ON(&quot;error&quot;)             Returns the command assigned in an ON ERROR statement.

?ON(&quot;KEY&quot;,&quot;F4&quot;)           Returns the command assigned to the F4 key in an ON KEY LABEL statement.

IF ON(&quot;PAGE&quot;)=&quot;DO MyUdf&quot;  Compares the command assigned to ON PAGE to                           the character string &quot;DO MyUdf&quot; and returns .T. or .F. NOTE: The ON function is documented in the FoxPro version 2.0 &quot;Commands & Functions&quot; manual after the ON SELECTION command. Additional reference words: FoxDos FoxWin 2.00 READ ERROR PUSH POP 2.50 2.50a KBCategory: kbprg KBSubcategory: FxprgGeneral
 * }