Re: Coercion of string to a record label
Re: Coercion of string to a record label
- Subject: Re: Coercion of string to a record label
- From: Bryan <email@hidden>
- Date: Wed, 10 Oct 2001 04:40:25 -0400
- Organization: Apex Radiology
the following uses the "MakeValueText" command of the PrefIO OSAX (Steve LoBasso)
alternatively, you may be able to use the "Coerce Record to Text" OSAX fro LNS for this.
----------------------------------------
on theprop(theproperty, theRecord)
run script "return " & theproperty & " of " & (MakeValueText theRecord)
end theprop
set myrecord to {a:1, b:"2"}
set myproperty to "a"
theprop(myproperty, myrecord)
-----------------------------------------
Bryan Kaufman
Harald E Brandt wrote:
>
+--> Olof Hellman wrote 01-10-09:
>
>Ah, my favorite topic. From a suggestion of mine, cleaned up by Emmanuel:
>
>
>
>to usrf(theList)
>
> script
>
> {+class usrf;:theList}
>
> end script
>
> run script the result
>
>end usrf
>
>
>
>usrf({"a", 1, "b", 2})
>
>
>
>--> {a:1, b:2}
>
+-
>
>
So I can make a record of a list.
>
But the task was to get the property value from a record, based on a property label given as a string. I don't really see how that can easily be done using the above method - although I might be blind.
>
>
I *do*, however, see how the above can be used to set a single property, although I really think it is inelegant (since it is a concatenation):
>
>
set myRecord to {EU:"123", US:"789"}
>
set aRegion to "eu" --got to be lower case
>
set myRecord to usrf({aRegion, "99"}) & myRecord
>
-->{EU:"99", US:"789"}
>
>
______heb________________________________________________________________
>
Harald E Brandt email@hidden PGP/MIME aware http://heb.bragit.com
>
_______________________________________________
>
applescript-users mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
[demime 0.98b removed an attachment of type text/x-vcard which had a name of bryan.vcf]