Re: interesting discovery (trying to get record labels as strings )
Re: interesting discovery (trying to get record labels as strings )
- Subject: Re: interesting discovery (trying to get record labels as strings )
- From: Olof Hellman <email@hidden>
- Date: Mon, 3 Dec 2001 17:15:11 -0800
Victor wrote :
>
The problem with records (as others have pointed out) is that
>
calling the keys
>
has to be hardwired into the code. The AppleScript team is
>
apparently working on
>
it, but that probably wouldn't be available for anything less
>
than MacOS X.
>
Actually no, it doesn't need to be hardwired. That's why I posted my
extract_exact_usrf handler a few days ago:
Note that extract_exact_usrf takes a variable as the key:
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
- Olof