Re: Convert Text to Variable Name
Re: Convert Text to Variable Name
- Subject: Re: Convert Text to Variable Name
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 14 Jan 2011 19:57:30 -0500
There are lots of reasons you might want to do this; most of them can
be worked around without having to actually do it, however. And I
don't think it can be done in AppleScript.
The principal problem is that these script objects can't access
variables from the surrounding context. If they could, then this
would work:
set myVar to 1
set varName to "myVar"
set varValue to (run script varName)
But instead you get this:
55:73: execution error: The variable myVar is not defined. (-2753)
On Fri, Jan 14, 2011 at 7:49 PM, Matthew Smith <email@hidden> wrote:
> On 15/01/2011, at 11:37 , Christopher Stone wrote:
>
> Well I thought I was reasonably clear in my first post but perhaps not.
> What I wanted was for you to return the value of varName starting with the
> text value "varName".
> set theVariable to path to home folder
> set anotherVariable to "theVariable"
> Now I want to return the value of theVariable starting
> with anotherVariable if it's possible.
> The outcome on my machine should be: alias "Odin:Users:stone:"
>
> I am having trouble understanding why you would want to do this. The closest
> I can come to understanding this in a programming context is the use of
> pointers. Another thought is you are trying to mimic a dictionary construct.
> Can you explain why you need a variable to contain the name of another
> variable and be able to reference it through this indirect method?
> Matthew Smith
> _______________________________________________
> 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