Language Guide

CHAPTER 7
Control Statements
204 Try Statements
Exit 7
An Exit statement is used in a Repeat statement to exit the Repeat statement.
When AppleScript executes an Exit statement, it terminates loop execution and
resumes execution with the next statement following the Repeat statement. You
cannot use Exit statements outside of Repeat statements.
SYNTAX
exit
EXAMPLE
set i to 1
tell application "Scriptable Text Editor"
repeat
if i > (count windows)
exit
end
print window i
set i to i + 1
end repeat
end tell
Try Statements 7
Scripts don’t always work perfectly. When a script is executed, errors can occur
in the Operating System (for example, when a specified file isn’t found), in an
application (for example, when you specify an object that doesn’t exist), and in
the script itself. When an error occurs, AppleScript sends a special message
known as an error message. An error message is a message that is returned by
an application, AppleScript, or the Operating System if an error occurs during
the handling of a command. An error message can include an error number,