The obvious answer is:
set Var1 to "Cat"
set Var2 to "Dog"
set Var3 to "Horse"
set Var4 to "Bird"
set ListAnimals to {Var1, Var2, Var3, Var4}
--Would Give ListAnimals = {"Cat","Dog","Horse","Bird"}
--Which is great if all Four Variables are always used.
-- BUT IF
set Var1 to "Cat"
set Var2 to "Dog"
set Var3 to ""
set Var4 to "Bird"
set ListAnimals to {Var1, Var2, Var3, Var4}
--Would Give ListAnimals = {"Cat","Dog","","Bird"}
--I want ListAnimals = {"Cat","Dog","Bird"}
-- Later I want to add
set Var5 to ""
set Var6 to ""
set Var7 to ""
set Var8 to ""
--etc. and do not know how many or which will be used at any one time.
I fully realize that I could do it the first way and then filter
out the empty Var3.
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.
To All of you for your responses on my question:
Thank you!
I have read each and every reply and appreciate the help provided.
As Always this users group is a great resource for information and support.
Oakley