Language Guide
CHAPTER 2
Overview of AppleScript
16 Statements
All statements, including control statements, fall into one of two categories:
simple statements or compound statements. Simple statements are statements
such as the following that are written on a single line.
tell application "Scriptable Text Editor" to print the front window
Compound statements are statements that are written on more than one line
and contain other statements. All compound statements have two things in
common: they can contain any number of statements, and they have the word
end (followed, optionally, by the first word of the statement) as their last line.
The simple statement of the first example in this section is equivalent to the
following compound statement.
tell application "Scriptable Text Editor"
print the front window
end tell
The compound Tell statement includes the lines tell application
"Scriptable Text Editor" and end tell, and all statements between
these two lines.
A compound statement can contain any number of statements. For example,
here is a Tell statement that contains two statements:
tell application "Scriptable Text Editor"
print front window
close front window
end tell
This example illustrates the advantage of using a compound Tell statement:
you can add additional statements within a compound statement.
Note
Notice that this example contains the statement print
front window instead of print the front window.
AppleScript allows you to add or remove the word the
anywhere in a script without changing the meaning of the
script. You can use the word the to make your statements
more English-like and therefore more readable. ◆