ON( ) Function

JavaScript Editor js editor     Web development 



Main Page

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

ON(cONCommand [, KeyLabelName])

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:
В Copy Code
? 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:
В Copy Code
? ON('KEY', 'F7')

Return Value

Character

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.

В Copy Code
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



JavaScript Editor js editor     Web development