Hi! I am a noob. :')
I’m trying to repeat through a list of numbers and then create variable names by appending the number to a string on each iteration.
repeat with i from 1 to amountOfFavourites
copy "location" & i to the end of favList
I have variables called location1, location2 and so on, and I want their values added to the list. I guess I’m not searching the web correctly, because I can’t find any info on it.
Argh, woe is me, the noobie.
I’m working on an FTP droplet now.
Okay, small progress:
set location1 to "hey"
set location2 to "you"
repeat with i from 1 to favCount
run script "set this_item to location" & i
copy this_item to the end of favList
The only problem is that the variable does not exist in the script that tries to set this_item to the value of location1 or location2.
I am thinking it has to do with variable scoping, but making the variables global doesn’t help!
I’m sure I’m overlooking something very basic here…
In AppleScript, the names of variables are simply an arrangement between you and the compiler. You can’t change them at run time or refer to them from run-time data.
I can’t quite see what you’re trying to achieve, otherwise I’d be a little more helpful with alternative code.
Thanks for the heads up!
I found a workaround for my problem. I’m so used to Actionscript and PHP that I keep thinking in the wrong terms ;')