Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

AppleScript Programming/Advanced Code List/Repeat

From Wikibooks, open books for an open world
<AppleScript Programming |Advanced Code List

With commandrepeat you can create repetative behavior, that often will shorten the code a lot, if done correctly.

Its basic format is this:

repeat 10 timessay "Hello."end repeat

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.

on open (ListItem)repeat with thisItem in ListItem-- bunch of kick*** codeend repeatend open

One example of actual script that utilizes repeat-function can be foundhere.

While, here is one example of code that will wait until a page in Safari is fully loaded:

tell application "Safari" to activate -- Brings Safari frontmost application.repeattell application "Safari"if source of document in window frontmost contains "</html>" thentell application "Script Editor" to activateexit repeat -- This will quit the loop.elsedelay 1 -- Will wait for 1 second.end ifend tellend repeat

And a useful source can be found from here:www.macobserver.com

The entire series of AppleScript columns at Mac Observer are herewww.macobserver.com/tips/applescript/

Next Page:  Say | Previous Page: Display Dialog
Home: AppleScript Programming/Advanced Code List
Retrieved from "https://en.wikibooks.org/w/index.php?title=AppleScript_Programming/Advanced_Code_List/Repeat&oldid=3803242"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp