Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

AppleScript Programming/Advanced Code List/Repeat

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

With command repeat you can create repetative behavior, that often will shorten the code a lot, if done correctly. Its basic format is this: <nowiki>repeat 10 times say "Hello." end repeat</nowiki> And it can be used to do a specific task for every item you drop into a script that has been turned into a program. <nowiki>on open (ListItem) repeat with thisItem in ListItem -- bunch of kick*** code end repeat end open</nowiki> One example of actual script that utilizes repeat-function can be found here. While, here is one example of code that will wait until a page in Safari is fully loaded: <nowiki> tell application "Safari" to activate -- Brings Safari frontmost application. repeat tell application "Safari" if source of document in window frontmost contains "</html>" then tell application "Script Editor" to activate exit repeat -- This will quit the loop. else delay 1 -- Will wait for 1 second. end if end tell end repeat</nowiki> And a useful source can be found from here: www.macobserver.com The entire series of AppleScript columns at Mac Observer are here www.macobserver.com/tips/applescript/ Say Display Dialog