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.

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.