An AppleScript list iterate/loop example

AppleScript list FAQ: How do I iterate/loop over an AppleScript list?

As I continue to work on my Mac speech recognition software projects, I’ve often found the need to loop over an AppleScript list. One way to loop over a list is to use the AppleScript repeat with syntax:

set myList to {"Hello", "Goodbye", "I must be going"}
repeat with theItem in myList
  say theItem
end repeat

In this example, I iterate over each item in my AppleScript list, and then use the AppleScript say command to speak each item in the list.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.