This should be obvious and easy, but I’ve spent a lot of time trying to make it work.
I have two lists, a list of variables, like this:
set varList to {var0, var1, var2}
and a list of strings:
set stringList to {“string zero”, “string one”, “string two”}
I want to assign var0 to “string zero”, var1 to “string one”, and var2 to “string two”.
This brute-force code works:
set var0 to ""
set var1 to ""
set var2 to ""
set varList to {var0, var1, var2}
set stringList to {"string zero", "string one", "string two"}
set var0 to item 1 of stringList
set var1 to item 2 of stringList
set var3 to item 3 of stringList
But this doesn’t work, obviously because I don’t know how to handle lists:
set var0 to ""
set var1 to ""
set var2 to ""
set varList to {var0, var1, var2}
set stringList to {"string zero", "string one", "string two"}
repeat with i from 1 to the count of varList
set item i of varList to item i of stringList
end repeat
What should I be doing that I’m not doing? (And if anyone knows a way to avoid those declarations of var0, etc., I’ll be glad to know what it is.)
Sorry for wasting bandwidth on something so simple.