Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 7 - Control Statements / If Statements

If (Compound Statement)

A compound If statement contains one or more Boolean expressions and groups of statements to be executed if the value of the corresponding Boolean expression is true.

if Boolean [ then ] 
   [ statement ]...
[ else if Boolean [ then ]
   [ statement ]...]...
[ else
   [ statement ]...]
end [ if ]

Boolean is an expression whose value is true or false.

statement is any AppleScript statement.

In the following If statement, the statements that copy an individual's status report to the end of a department status report are executed only if the date is March 1, 1993.

if Current Date = "March 1, 1993"
   tell application "Scriptable Text Editor"
      open file "Status Report"
      set myStatus to text from paragraph 1 to ÿ
         paragraph 10 of document "Status Report"
      close document "Status Report"
      open file "Department Status"
      copy myStatus to end of document "Department Status"
      close document "Department Status"
   end tell
end if

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996