I am trying to have a list of applescript items but the things i'm adding are strings with multiple words. When I try to view lets say item 1 of my list, it ends up being all of the items in the list. I'm doing this from a repeat which might make a difference but I am very confused so anything that you think might work just post it. Thanks!!!
1 Answer
Here's how you do it. This shows 2 types of repeat loops and how you use them. Good luck!
set myList to {"some words", "more of them", "and a lot of words"}
repeat with i from 1 to count of myList
set thisItem to item i of myList
-- do something with thisItem
end repeat
-- or another way to do a repeat loop
repeat with anItem in myList
set thisItem to contents of anItem
-- Notice if we use a repeat loop like this (e.g. anItem) then anItem
-- is just a reference to the words. To actually get the words
-- we need to get the contents of anItem
end repeat
2 Comments
mikemmb73
Do you know the correct way to add another item to the end of the list?
regulus6633
set end of myList to "another item"... You should go here (macscripter.net/viewtopic.php?id=25631) and do the tutorials called "AppleScript Tutorial for Beginners". It's how I learned. There's one for lists.