Re: As Alias List
Re: As Alias List
- Subject: Re: As Alias List
- From: Axel Luttgens <email@hidden>
- Date: Sat, 21 Nov 2009 08:22:01 +0100
Le 20 nov. 2009 à 20:17, Luther Fuller a écrit :
> I've just wasted a couple of hours trying to discover why an old script is soooo slow. It's still slow, but I discovered a problem in this snippet of code ...
>
> set prefFileList to (sort items of prefsRef by name) as alias list
> repeat with itemRef in prefFileList
> select itemRef
>
> It was throwing an error every time I tried to run it. Finally, I inserted a diagnostic only to discover that the items of the list prefFileList are not aliases, but references. So I inserted one line ...
>
> set prefFileList to (sort items of prefsRef by name) as alias list
> repeat with itemRef in prefFileList
> set itemRef to (itemRef as alias)
> select itemRef
>
> and now it runs properly.
>
> So, what's wrong with as alias list ?
Hello Luther,
I guess that at least some part of above code is wrapped into a tell app "Finder" block, otherwise the "as alias list" locution wouldn't make sense.
Let's consider try this one:
tell application "Finder"
files of desktop
(sort result by name) as alias list
--> a list of Finder references
end tell
and compare it to that one:
tell application "Finder"
files of desktop as alias list
--> a list of aliases
end tell
In fact, the Finder may be asked to create a list of aliases instead of a list of references when the list is produced (created), and only at that moment.
Another example:
tell application "Finder"
(files of desktop whose name begins with "a") as alias list
--> a list of aliases
end tell
As soon as the list exists, it's too late: "as alias list" is a no-op.
Here, the Finder creates a list of references, then sorts that list, then applies "as alias list" on an already existing list:
tell application "Finder"
(sort files of desktop by name) as alias list
--> a list of references
end tell
One could be disappointed by the limited scope of "as alias list".
But there's nothing wrong with it, it just works as intended. ;-)
HTH,
Axel _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden