Re: Dynamic Records?? (or other alternatives)
Re: Dynamic Records?? (or other alternatives)
- Subject: Re: Dynamic Records?? (or other alternatives)
- From: Olof Hellman <email@hidden>
- Date: Thu, 29 Nov 2001 13:28:48 -0800
This is from my Oct 10, 2001 posting about how to do this. usrf() is the
routine which generates a record on the fly from a list.
extract_exact_usrf() is the routine which, given a record generated by
usrf(), extracts the tag denoted by a string. Note that this is fairly
hackish -- involving script object handler assignment ( danger Will Robinson
! ) -- but does support tag names not in all caps or even with spaces.
And yes, +class usrf; should have the chevrons instead of those ugly
punctuation things.
Enjoy,
Olof
to extract_exact_usrf(theRecord, fieldName)
script Fred
property r : theRecord
to extract()
end extract
end script
set Amy to run script "script George
property r : {}
to extract()
return |" & fieldName & "| of r -- note the bars!!
end extract
end
George"
set Fred's extract to Amy's extract
return (Fred's extract())
end extract_exact_usrf
to usrf(theList)
script
{+class usrf;:theList}
end script
run script the result
end usrf
set usrfRecord to usrf({"EU", 3, "b", 2})
-->{|EU|:3, b:2}
-- now use the string "EU" to get record item |EU|
extract_exact_usrf(usrfRecord, "EU")
--> 3