EU as text
EU as text
- Subject: EU as text
- From: List Guy <email@hidden>
- Date: Tue, 09 Oct 2001 08:35:55 -0700
" That's easy, but I want "EU" to come from a string variable, like: set
aRegion to "EU""
I haven't seen Neal answer yet, so:
(one note: the "class form" should be enclosed in chevrons -- I'm not sure
how it will appear on the mailing list.)
[BEGIN BRILLIANT SOLUTION]
Calculating a Property Label
"Neal A. Crocker" <email@hidden>
------------------------------------------------------------------
set z to "red"
set color_record to {red:1.254, yellow:56.401, blue: 23.9}
get makereference(z,color_record)
------------------------------------------------------------------
I started playing around with the "run script" command to try and make a
function that returns a reference to a field in a record given the name of
the field as a string and the record as arguments. I eventually figured it
out and I've included it below. Please read the notes below the script.
It's tricky to compile! (By the way, the "target" argument of the
"makereference" function can be a script with a "bar" property rather than a
record with a "bar" field.)
-------------------------------------------------------------------
on makereference(propname, target)
script refscript
--{class:reference,+class form;:+constant ****usrp;, +class
want;:+class prop;, +class seld;:propname, +class from;:target}
{class:reference, +class form;:+constant ****usrp;, +class
want;:property, +class seld;:propname, from:target}
end script
run script refscript
end makereference
set blah to makereference("bar", {bar:2})
{blah, blah + 1} -- {bar of {bar:2}, 3}
-------------------------------------------------------------------
The script "refscript" inside the function "makereference" has a commented
line and an uncommented line. The uncommented line won't compile because
script editor chokes on the use of the words "from" and "property".
However, to compile the script, the uncommented line can be deleted and the
commented line can be uncommented. Then the script will compile. The
formerly commented line will be converted by script editor to look like the
uncommented which was deleted. If you plan to compile a script containing
this function more than once, it is best to make a copy of the commented
line for reuse.
[END BRILLIANT SOLUTION]
grh