Language Guide

CHAPTER 7
Control Statements
184 Characteristics of Control Statements
Characteristics of Control Statements 7
Most control statements are compound statements that contain other state-
ments. For example, the If statement
if today = last day of theMonth
set MonthlyReport to prepareReport(currentMonth)
print MonthlyReport
end if
is a compound statement that contains a Set command and a Print command.
Compound statements begin with one or more reserved words, such as if in
the example above, that identify the type of compound statement. The last line
of a compound statement is always end, which can optionally include the
word that begins the control statement.
Control statements can contain other control statements. For example, this Tell
statement contains the If statement of the previous example.
tell application "ReportWizard"
if today = last day of theMonth
set MonthlyReport to prepareReport(currentMonth)
print MonthlyReport
end if
end tell
Control statements that are contained within other control statements are
sometimes called nested control statements.
All control statements can be compound statements. In addition, some control
statements can be written as single statements. For example, the statement
if (x > y) then return x
is equivalent to
if (x > y) then
return x
end if