Language Guide

CHAPTER 7
Control Statements
196 Repeat Statements
Note that two of the strings in the preceding statement include a return
character. These are valid strings even though the surrounding quotation
marks are on different lines within the statement. Running the preceding
statement results in the following text:
David Numberman's Top 10 Numbers for Lists
1. 1
2. 2
3. 3
4. 4
5. 5
6. 6
7. 7
8. 8
9. 9
10. 10
The line
repeat with n from 1 to 10
specifies n as the looping variable, a variable that controls the number
of iterations.
At the beginning of each iteration, AppleScript adds 1 to the value of n. When
the value of the looping variable reaches 10, AppleScript exits the loop.
The expression n as string coerces an integer into a string, while the &
(concatenation) operator joins two strings to make a single string. For more
information about operators and coercing values, see Chapter 6, “Expressions.”