ON() Function Returns Command Assigned to Handle Event

Last reviewed: June 27, 1995
Article 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(<expC1> [, <expC2>])

where <expC1> specifies one of the event classes. Valid values for <expC1> include the following:

   Command             <expC1>
   -------             -------

   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 <expC2> parameter.

The following are examples of using the ON() function:

X=ON("error")              Returns the command assigned in an ON ERROR
                           statement.

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

IF ON("PAGE")="DO MyUdf"   Compares the command assigned to ON PAGE to
                           the character string "DO MyUdf" and returns
                           .T. or .F.

NOTE: The ON() function is documented in the FoxPro version 2.0 "Commands & Functions" 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


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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.