Language Guide

CHAPTER 7
Control Statements
Repeat Statements 197
Repeat (forever) 7
The Repeat (forever) form of the Repeat statement is an infinite loop. The only
way to exit the loop is by using an Exit statement.
SYNTAX
repeat
[ statement ]...
end [ repeat ]
where
statement is any AppleScript statement.
This is an infinite loop; you must use an Exit statement to exit the loop
(see page 204).
EXAMPLE
The following example numbers the paragraphs of a document. It uses the
Exit statement
if paragraphNum > numParagraphs then exit
to exit the loop.
tell document "List"
set numParagraphs to (count paragraphs)
set paragraphNum to 1
repeat
if paragraphNum > numParagraphs then exit
set paragraph paragraphNum to (paragraphNum as string) & " "
& paragraph paragraphNum
set paragraphNum to paragraphNum + 1
end repeat
end tell