Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Lesson 11. The Repeat Loop > repeat [number] times

repeat [number] times

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:

Script 11.7.

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"


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial