Re: Copy to list Question
Re: Copy to list Question
- Subject: Re: Copy to list Question
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 14 Apr 2009 22:45:49 -0400
We're inferring a lot from not much of a description. It'd be nice if
Oakley would weigh in with more information about the problem being
solved.
Obviously, the whole thing can be replaced with one line if you have
all the information at the time of writing the script:
set ListAnimals to { "Cat", "Dog", "Horse", "Bird" }
Your solution, on the other hand, allows the values of the variables
to be unknown, but still assumes that we know *how many* variables
there are. Usually in that case you wouldn't bother with a loop.
This whole thing is similar to the whole records-as-associative-arrays
brouhaha; it's all in the statement of the problem. How is your
mystery record getting initialized in such a way that you don't have
all the keys at the time you write the script? In this case, the
question is, where are these mysterious variables coming from?
On Tue, Apr 14, 2009 at 9:39 PM, Peter Baxter <email@hidden> wrote:
> This still seems overly complicated:
> How about:
>
> set ListAnimals to ""
> set Var1 to "Cat"
> set Var2 to "Dog"
> set Var3 to "Horse"
> set Var4 to "Bird"
> try
> set ListAnimals to {Var1, Var2, Var3, Var4}
> end try
>
>
> ListAnimals
> On 15/04/2009, at 10:51 AM, Brian Christmas wrote:
>
> On 15/04/2009, at 10:43 AM, M Pulis wrote:
>
> cool... learned something new!
> thanks folks!
> gary
> On Apr 14, 2009, at 5:14 PM, Peter Baxter wrote:
>
> Hi Oakley
>
> It's quite easy to do this, however you need to define Varx seperately:
> set ListAnimals to ""
> set Var1 to "Cat"
> set Var2 to "Dog"
> set Var3 to "Horse"
> set Var4 to "Bird"
> set ListAnimals to {}
> repeat with x from 1 to 4
> set varx to "Var" & x
> set ListAnimals to ListAnimals & varx
> end repeat
> ListAnimals
>
> G'day
> This DOES NOT WORK!
> It returns {"Var1", "Var2", "Var3", "Var4"}
> because you're creating a text string with the
> line set varx to "Var" & x, not a variable.
> Regards
> Santa
>
> _______________________________________________
> 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
>
> _______________________________________________
> 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
>
--
Mark J. Reed <email@hidden>
_______________________________________________
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