• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: As Alias List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: As Alias List
      • From: Brian Christmas <email@hidden>
References: 
 >As Alias List (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: TextEdit Slash SearchReplace impossible (was Basic Script Blues)
  • Next by Date: Re: As Alias List
  • Previous by thread: As Alias List
  • Next by thread: Re: As Alias List
  • Index(es):
    • Date
    • Thread