Re: does property exists in a record
Re: does property exists in a record
- Subject: Re: does property exists in a record
- From: Helmut Fuchs <email@hidden>
- Date: Fri, 10 Aug 2001 17:11:21 +0200
At 0:33 Uhr +1000 11.08.2001, Adam Hinshaw wrote:
is there a way then to coerce a string to a record property ??
You can use the run script command from the Standard Additions for
this purpose:
set aSymbolName to "that's a funny symbol"
set aRecord to {anEntry: anything}
set aRecord to aRecord & (run script "{|" & aSymbolName & "|: anything}")
==> {anEntry: anything, |that's a funny symbol|: anything}
But as far as I know there's no way back, i.e. no way to coerce the
symbols back to strings - rendering this method useless when it comes
to using arbitrary symbols. And from what I understand that's just
what you want to do: create arbitrary properties in records and be
able to read them.
If you know that the properties you are searching for are from a
limited subset, you at least can check for existence _if_ you know
the value this contains:
set bRecord to (run script "{anEntry: anything}")
aRecord contains bRecord
==> true
In NewtonScript symbols (in our case "property names") were just
another datatype, so it was easy to iterate through records and do
whatever you want with them. Maybe somebody out there knows of a
simple method to do just that?
Helmut
--