AppleScript cycle:
(* * 1. Repeat dead Loop *) Set num to 0display dialog num--simplest loop, is dead loop repeatset num to num + 1display dialog numif num≥10 thenexit Repeatend IfEnd Repeat
(* 2. Number of cycles repeat n times where n can be a variable, can be a constant *)--Create global variable Numset num to 0global numset N to 6--limit loop n repeat n timesrun dial Ogscriptend repeat--Creating custom scripts Script Dialogscriptset num to num + 1display dialog numend script
(* 3. Print 0 ~ 9*) set num to 0--until type loop (*repeat until Num≥10display dialog numset num to num + 1end repeat*)--type loop repeat WHI Le num < 10display dialog numset num to num + 1end Repeat
--Variable loop--advantage: can adjust the span, by Num can be omitted, default is 1repeat with I from 0 to ten by 3display dialog Iend Repeat
--List Loop set students to {"Zhang San", "John Doe", "Harry"}--note here I is the pointer, want to get the content to use contents of I get repeat with I in Studentsdisplay Dialog Contents of Iset (contents of i) to "Xiao Ming" end Repeatdisplay Dialog "" & Students
Efficiency Chapter--applescript Introduction 2