Partilhar via


ON( ) Function

Returns the command assigned to each of these event-handling commands: ON ERROR, ON ESCAPE, ON KEY LABEL, or ON PAGE.

ON(cONCommand [, KeyLabelName])

Return Values

Character

Parameters

  • cONCommand
    Specifies one of the event-handling commands. Here are the commands and corresponding character expressions to use with ON( ):

    Command cONCommand
    ON ERROR ERROR
    ON ESCAPE ESCAPE
    ON KEY LABEL KEY
    ON PAGE PAGE

    For example, to return the command currently assigned to ON ERROR, use the following:

    ? ON('ERROR')
    
  • KeyLabelName
    Used in ON KEY LABEL to specify a key or key combination to which the command is assigned. Specify KEY in cONCommand and the key label name of the key or key combination in KeyLabelName. For a complete list of key label names, see ON KEY LABEL.

    For example, to return the command currently assigned to the F7 function key with ON KEY LABEL, use the following:

    ? ON('KEY', 'F7')
    

Remarks

When an event occurs that is trapped by one of the event-handling commands, the command assigned by the event-handling command executes. ON( ) returns the command you assigned to an event-handling command. ON( ) returns an empty string if a command isn't currently assigned to the event-handling command you specify.

Example

The following example uses ON( ) to display ON ERROR and ON KEY LABEL settings.

ON ERROR DO errorhand
ON KEY LABEL CTRL+F2 WAIT WINDOW 'You pressed ^F2'
ON KEY LABEL ALT+Z DISPLAY MEMORY
CLEAR
? ON('ERROR')  && Displays DO errorhand
? ON('KEY', 'CTRL+F2')  && Displays WAIT WINDOW 'You pressed ^F2'
? ON('KEY', 'ALT+Z')  && Displays DISPLAY MEMORY
ON ERROR
ON KEY LABEL CTRL+F2
ON KEY LABEL ALT+Z

See Also

INKEY( ) | LASTKEY( ) | ON ERROR | ON ESCAPE | ON KEY | ON KEY LABEL | ON PAGE | ON READERROR | READKEY( )