Re: Info about AppleScript records
Re: Info about AppleScript records
- Subject: Re: Info about AppleScript records
- From: Malcolm Fitzgerald <email@hidden>
- Date: Wed, 09 May 2001 11:29:33 +1000
>
> On 7/05/2001 11:40 PM, "Matthew Broms" <email@hidden> wrote:
>
>> Specifically right now, I9m looking for a way to dynamically set the
>
>> key/value pair of a record.
>
>
>
> For all practical purposes, you can't. It is really the single modern
>
> language feature which is missing from AS and is the single biggest handicap
>
> in terms of using AS as a substitute for Php and asp on web servers.
>
> Hopefully Apple are at work addressing this limitation...
>
>
Whoa there Tim! You certainly can.
>
>
set datastream to "set x to {key:\"value\"}"
>
set dynamiclyGeneratedRecord to run script datastream
>
-->{key:"value"}
I'd love to do this sort of thing, but of course the thing is to be able to
use variable keys. So I wrote:
set mKey to "asa_serviceType"
set mValue to "Manuscript Assessment"
set datastream to "set x to {" & mKey & ":\"" & mValue & "\"}"
set dynamiclyGeneratedRecord to run script datastream
asa_servicetype of dynamiclyGeneratedRecord
-- returns "Manuscript Assessment"
but I really need to say
mKey of dynamiclyGeneratedRecord
-- returns error: can't get mKey of {asa_servicetype:"Manuscript
Assessment"}
Using run script to get around this doesn't help, as the following shows
set reqStream to mKey & " of dynamiclyGeneratedRecord"
set myReq to run script reqStream
-- returns "The variable dynamiclyGeneratedRecord wasn't defined"
>
But, some people don't like 'run script' constructions. And they can slow
>
down execution (supposedly.untested.) if repeatedly used. SO...
>
If you don't mind OSAXen then you can get RecordAccess from Ed Lai.
>
>
RecordAccess OSAX (Ed Lai - Apple computer 1999)
>
It allows one to combine two lists to make records, get the keys of a
>
record as a list and get the value of a given key.
>
It's available in only one place that I know of. Ed Lai's public folder
>
on his iTools account. email@hidden.
>
>
--
>
Paul Skinner
So I went to look at Ed Lai's RecordAccess OSAX.
I have the same problem with it: I can't say
(item 1 of recLabels) of theRecord
In addition, it returns the record labels in pipes sometimes, but not
always. I can't see why but seeing that I can't refer to record labels with
list references it doesn't matter much.
--
Malcolm Fitzgerald
Database Manager
The Australian Society of Authors
email@hidden ph:02 93180877 fax: 02 93180530
http://www.asauthors.org