Re: Coercing document list to alias list
Re: Coercing document list to alias list
- Subject: Re: Coercing document list to alias list
- From: has <email@hidden>
- Date: Wed, 13 Dec 2006 19:16:26 +0000
Mahlon Lovett wrote:
Here's where I'm puzzled:
Select one item in a folder in the Finder and script #1 returns
an alias;
select more than one item and it returns a list in the form
{document file
of "" of folder "", ...} -- not an alias list.
It's a 'feature' of AppleScript: coercing _any_ list to «class alst»
simply returns a copy of that list, regardless of what's in it. For
example, you'd expect the following code to raise a coercion error,
but AS returns a value instead:
{1, 2, 3} as «class alst»
--> {1, 2, 3}
I'm guessing it's a deliberate kludge slipped into AS to work around
the problems caused by its over-eager 'as' operator that I described
in my earlier post. It's not terribly discriminating though, as you
can tell. (Hacks upon hacks... never a good recipe for reliability.
Did I mention this stuff works just fine in Python/Ruby?;)
For my work, what this means is that, getting an alias list is easy
if the
goal is operate on every item in a folder -- just use script #2. To
operate
on a selection of items, it's necessary to use a repeat loop and
build the
alias list 'by hand' -- i.e., the tedious way.
Correct. If you have a Finder reference identifying multiple
filesystem objects, you can tell the Finder to convert that reference
to a list of aliases for you. If you have a list of Finder
references, you have to process each list item yourself.
has
--
http://freespace.virgin.net/hamish.sanderson/
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden