Re: Calling a property by using a string
Re: Calling a property by using a string
- Subject: Re: Calling a property by using a string
- From: Philip Aker <email@hidden>
- Date: Mon, 25 Sep 2006 12:38:58 -0700
On 2006-09-25, at 08:43:34, Chris Tangora wrote:
I am trying to get this to work, and I was hoping to have someone
help me figure out the small detail I am missing. The idea is
this, take two strings, put them together and have it be the name
of a previously declared property. Ideally the end result of the
sample script would be "This Worked", not "Great_Test".
property Average_Test : "Please Don't Work"
property Good_Test : "Shouldn't Work"
property Great_Test : "This worked"
set this to "Great"
set test to "_Test"
set thistest to (this & test)
log thistest
The ultimate ending will be used in AppleScript Studio, but it
would be nice to have it work in both Studio and non-Studio apps.
Does anybody know a way to convert a string to a previously
declared variable?
You can achieve this goal in TclOSA.component by mixing languages:
#######
set x "good"
set y "_one"
set xy $x$y
set z x
append z y
set script {
property xy : "bad_one"
}
append script "\nset $z to \"[set $z]\"\n"
append script {return xy}
osa::do_script ascr "$script"
#######
The result of the above script is: good_one
You can call TclOSA from AppleScript by using "run script xxx in
"Tcl". However, as you can probably imagine, the quoting gets
impossibly messy when calling a language from a language from a
language, so it's better to use load script and run it in that case.
Philip Aker
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:
This email sent to email@hidden