Language Guide
CHAPTER 2
Overview of AppleScript
Commands and Objects 17
Here’s another example of a compound statement:
if the number of windows is greater than 0 then
print front window
end if
Statements contained in a compound statement can themselves be compound
statements. Here’s an example:
tell application "Scriptable Text Editor"
if the number of windows is greater than 0 then
print front window
end if
end tell
Commands and Objects 2
Commands are the words or phrases you use in AppleScript statements to
request actions or results. Every command is directed at a target, which is
the object that responds to the command. The target of a command is usually
an application object. Application objects are objects that belong to an
application, such as windows, or objects in documents, such as the words
and paragraphs in a text document. Each application object has specific
information associated with it and can respond to specific commands.
For example, in the Scriptable Text Editor, window objects understand the Print
command. The following example shows how to use the Print command to
request that the Scriptable Text Editor print the front window.
tell application "Scriptable Text Editor"
print front window
end tell
The Print command is contained within a Tell statement. Tell statements
specify default targets for the commands they contain. The default target is the
object that receives commands if no other object is specified or if the object is