Re: Rogue list?
Re: Rogue list?
- Subject: Re: Rogue list?
- From: "Arthur J Knapp" <email@hidden>
- Date: Tue, 08 May 2001 13:32:08 -0400
>
Date: Mon, 7 May 2001 11:18:11 -0700
>
From: Chris Espinosa <email@hidden>
>
Subject: Re: Rogue list?
>
> tell application "Finder"
>
> set theClients to name of folders of myFolder
>
> log class of theClients
>
> --if theClients = {} then set theClients to {}
>
> set end of theClients to "New"
>
> theClients
>
> I get an error that I "Can't set end of {} to "New"." But when I
>
> uncomment
>
> the line before, it works. Any explanations?
>
Yes, a simple one.
>
>
When the Finder returns an empty value collective Get Data operation
>
(anything with a plural anywhere in the direct object, such as your
>
"name of folders of myFolder"), it doesn't return an empty list, it
>
returns an empty *record*. Which looks and prints and smells like an
>
empty list, and compares correctly to an empty list, but can't do
>
list-like things, like having its end set. Your commented-out line is
>
unfortunately the correct workaround, 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;:{}}"
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.
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
...
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://MacScripter.net