• 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: Alias List not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alias List not working


  • Subject: Re: Alias List not working
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 1 Sep 2009 23:08:18 +0200

Le 1 sept. 09 à 18:09, Luther Fuller a écrit :

I've been experimenting with this script trying to find why a variable that should be an alias ... isn't.

tell application "Finder"
	activate
	try
		set sourceFolder to (target of window index 1) as alias
	on error
		beep
		return
	end try
	if class of item sourceFolder is not folder then return
	--
	set itemList to (get items of sourceFolder as alias list)
	-- set itemList to (sort itemList by modification date) -- line 1
	-- set itemList to reverse of itemList as alias list -- line 2

	set itemList to (itemList as alias list)

	set itemAlias to (item 1 of itemList) -- as alias -- line 3
	(class of itemAlias)
	display dialog the result as text
end tell

If you run this "as is", the dialog shows "alias".

But, if you run it with the two commented-out lines restored, the dialog shows "folder" or "document file" & c. Further, I am not able to coerce the list to an alias list by using

	set itemList to (itemList as alias list)

but I can restore the 'as alias' in line 3 to get what I need.

The problem seems to be line 1. If only line 1 is commented-out, you get correct behavior.

It seems that a 'sorted' list of references cannot be coerced to a list of aliases.

Let's have a simplified version of your script:

	tell application "Finder"
		-- This will set S to an alias for folder S on my desktop...
		set S to folder "luther" of desktop as alias
		-- ... but I must convert S into a finder reference so as to
		-- check whether S really is a folder.
		class of item S
		-- Now I ask to have a list of aliases for the items in S...
		set IL to items of S as alias list
		-- ... but the Finder needs to convert all those aliases back
		-- into finder references for being able to sort those items.
		set IL to sort IL by modification date
		-- This is just an AppleScript operation.
		set IL to reverse of IL
		-- Since the Finder doesn't produce any list of references here,
		-- the "as alias list" part is plain ineffective.
		set IL to IL as alias list
	end tell

Notwithstanding all those questionable reference<->alias conversions, the point here is that "as aliast list" isn't a coercion operator. It is just a locution telling the Finder to produce a list of aliases instead of a list of file references when asked to create such a list.

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
References: 
 >Alias List not working (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Snow Leopard AppleScript Release Notes
  • Next by Date: Script Fails in Snow Leopard - Adobe Unit Types.osax
  • Previous by thread: Alias List not working
  • Next by thread: Mail.app Schedules
  • Index(es):
    • Date
    • Thread