Language Guide
CHAPTER 8
Handlers
Command Handlers 241
Command Handlers 8
Command handlers are handlers for application commands. They are similar
to subroutine handlers, but instead of defining responses to user-defined
commands, they define responses to application commands, such as Open,
Print, or Move, sent to application objects.
You define command handlers in scripts, but they handle commands that are
sent to application objects. To be useful, scripts that contain command handlers
must be associated with the application objects that receive those commands.
This is called attaching a script to an application object.
Scripts that are attached to objects can change the way those objects respond to
particular commands. Each application determines which, if any, of its objects
can have attached scripts, and how you attach the scripts.
This section describes the syntax for command handler definitions. For
information about recursion in command handlers, see the“Recursive
Subroutines,” which begins on page 225. For information about the scope
of variables and properties in handlers, see “Scope of Script Variables and
Properties,” which begins on page 252.
Command Handler Definition 8
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.