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: Harald E Brandt <email@hidden>
- Date: Tue, 9 Oct 2001 22:57:44 +0200
+--> 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