Re: Copy to list Question
Re: Copy to list Question
- Subject: Re: Copy to list Question
- From: Axel Luttgens <email@hidden>
- Date: Thu, 16 Apr 2009 10:12:05 +0200
Le 16 avr. 09 à 00:30, Oakley Masten a écrit :
[...]
All I wanted to know was if it was POSSIBLE to do it with the repeat
command
and use a dynamically created variable name.
repeat with x from 1 to 4
copy (Var & x) to ListAnimals
end repeat
The answer appears to be NO if using only AppleScript.
[...]
Hello Oakley,
In fact, ApleScript allows for lots of tricks. The problem is that
they are just... tricks. But it's always amusing to play with them. ;-)
So, strictly for academic purposes, here's another one:
property Var1 : "Cat"
property Var2 : "Dog"
property Var3 : "Horse"
property Var4 : "Bird"
on getVal(varName)
run script "
on run {R}
R's " & varName & "
end run
" with parameters {a reference to me}
end getVal
set ListAnimals to {}
repeat with I from 1 to 4
set end of ListAnimals to getVal("Var" & I)
end repeat
ListAnimals
--> {"Cat", "Dog", "Horse", "Bird"}
It appears cleaner to make use of properties; but, because of a
scoping clash between top-level properties and globals, one could just
make use of implicit globals as well (i.e., 'set Var1 to "Cat"'
instead of 'property Var1 : "Cat"' in the above).
Axel _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden