0

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 1

3

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
Sign up to request clarification or add additional context in comments.

2 Comments

Do you know the correct way to add another item to the end of the list?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.