如何使用循环变量运行Applescript循环

时间:2014-07-21 16:08:04

标签: loops applescript

我已经仔细寻找答案了,我似乎无法找到一个(或至少一个我理解的)。

是否可以在?

中运行带有循环变量的applescript循环

例如 - 让我们说我想用另一个列表重命名列表中的每个项目:

    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 个答案:

答案 0 :(得分:3)

我认为你想要的是......

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}