Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Most of the previous examples used a counter variable to determine when the script should terminate, breaking out of the infinite loop with a return or exit statement. AppleScript provides several more direct and efficient ways to do this. The first one we’ll examine is the repeat [number] times statement. You already saw one example at the beginning of this chapter. It used a counter variable, too, but not to control when the repeat loop terminated. Script 11.7 shows another example:
display dialog "Make three wishes." repeat 3 times display dialog "I wish that..." default answer "" end repeat display dialog ("Just fooling!") ¬ buttons {"Too Bad"} default button "Too Bad" |