0

I've scoured for an answer to this and I can't seem to find one (or at least one that I understand).

Is it possible to run an applescript loop with a looping variable within?

For example - let's say I wanted to rename each item in a list using another list:

    set myFirstList to {"1", "2", "3"}
    set mySecondList to {"A", "B", "C"}

    repeat with i in myFirstList
        --change '1' to 'A', change '2' to 'B', etc
        set name of i to first item of mySecondList, then second item of mySecondList, ???
    end repeat

1 Answer 1

3

I think that you want is...

set myFirstList to {"1", "2", "3"}
set mySecondList to {"A", "B", "C"}

set myFirstListCount to count myFirstList
repeat with i from 1 to myFirstListCount
    set item i of mySecondList to item i of myFirstList
end repeat

return {myFirstList, mySecondList}
Sign up to request clarification or add additional context in comments.

Comments

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.