Language Guide

CHAPTER 9
Script Objects
268 Sending Commands to Script Objects
Sending Commands to Script Objects 9
You use Tell statements to send commands to script objects. A Tell statement
sent to a script object is similar to a Tell statement sent to an application, except
that it uses a variable name, instead of a reference, to identify the script object.
For example,
tell John
sayHello to "Herb"
sayHello to "Grace"
end tell
sends two sayHello commands to the script object John. The parameters of
the commands in the Tell statement, if any, must match the parameters defined
in the handler definitions in the script object definition. For example, the
statement
tell John
sayHello ("Herb")
end tell
--results in an error
results in an error message because the handler definition for the sayHello
command (shown earlier in this chapter) defines a labeled parameter, not a
positional parameter.
For a script object to respond to a command within a Tell statement, either the
script object or its parent script object must have a handler for the command. A
parent script object is a script object from which a script object inherits handlers
and properties. (For more information about parent script objects, see
“Inheritance and Delegation” on page 271.)
The one command that any script object can handle, even without an explicitly
defined handler, is the Run command. A handler for the Run command can
consist of all statements at the top level of a script object definition other than
property and handler definitions. If the script object definition contains only