Re: Rogue list?
Re: Rogue list?
- Subject: Re: Rogue list?
- From: Chris Espinosa <email@hidden>
- Date: Wed, 9 May 2001 10:52:51 -0700
On Tuesday, May 8, 2001, at 06:09 PM, Arthur J Knapp
<email@hidden> wrote:
>
> as there's no way to specify an
>
> empty record in AppleScript itself.
>
>
I'm out of my league here, but I think that you can generate such
>
a thing:
>
>
set emptyRecord to run script "{+class usrf;:{}}"
Clever! (For those who don't know what is going on, he's manually
creating a record with one element, an empty list with the record tag
'usrf'. AppleScript uses the 'usrf' record tag to list user identifiers
that aren't in any app's terminology. By using 'run script" he's
causing that to be evaluated, and it evaluates to an empty record. It
has the same properties as the thing returned from the Finder, i.e. you
can't set the end of it.)
Also, if you happen to use Script Debugger 2.0, you can obtain
>
an empty record by asking for:
>
>
set emptyRecord to user data of window 1
>
>
but only while the script is being executed by SD 2.0. "user data" is
>
a property of script windows, as a part of Script Debugger's scripting
>
model.
There are probably many applications that accidentally return an empty
record. There's really no reason to.
>
>
You can also keep a text file around whose contents are:
>
>
reco$00$00$00$00
>
>
where "$00" is ASCII character 0. You could then read this empty
>
record into memory whenever you needed it:
>
>
set emptyRecord to read alias "MacHD:Folder:EmptyRecord" as record
>
>
A good way to do this for a script project might be to load such
>
a value at compile-time:
>
>
property kEmptyRecord : read alias "MacHD:Folder:EmptyRecord" as
>
record
>
>
on run
>
>
-- stuff
>
>
if ( someValue = kEmptyRecord ) then
>
>
...
I wouldn't recommend this as an empty record actually has the correct
Apple event structure for a record, where yours has NULL. You could get
the empty record in either of the ways you detail above and write it to
the file, then proceed as above.
Chris