Command Handler Definition
A command handler definition is a set of statements that is executed in response to an application command. Command handler definitions need
not include all of the possible parameters of the commands they respond to.
If a command handler receives more parameters than are specified in the command handler definition, it ignores the extra parameters.SYNTAX
The syntax for a command handler definition is
( on | to ) commandName � [ [ of ] directParameterVariable ] � [ given label:paramVariable [, label:paramVariable ]...] [ global variable [, variable ]...] [ local variable [, variable ]...] [ statement ]... end [ commandName ]wherecommandName (an identifier) is a command name.
directParameterVariable (an identifier) is a parameter variable for the actual value of the direct parameter. You use this parameter variable to refer to the direct parameter in the body of the subroutine. If it is included, directParameter must be listed immediately after the command name. The word
of
before directParameter is optional.label is the parameter label for one of the parameters of the command being handled. The label
given
is optional.paramVariable (an identifier) is a parameter variable for the actual value of the parameter. You use this identifier to refer to the parameter in the body of
the handler.variable is an identifier for either a global or local variable that can be used in the handler. The scope of a local variable is the handler. You cannot refer to a local variable outside the handler. The scope of a global variable can extend to any other part of the script, including other handlers and script objects. For detailed information about the scope of local and global variables, see "Scope of Script Variables and Properties," which begins on page 252.
statement is any AppleScript statement.
NOTES
The statements in a command handler can include a Continue statement, which passes the command to the application's default handler for that command. This allows you to invoke an application's default behavior for a command from within a command handler. For more information, see "The Continue Statement," which begins on page 277.