Re: AppleScript bug/change/feature in iTunes 7.7.1?
Re: AppleScript bug/change/feature in iTunes 7.7.1?
- Subject: Re: AppleScript bug/change/feature in iTunes 7.7.1?
- From: Doug Adams <email@hidden>
- Date: Sat, 02 Aug 2008 12:59:33 -0400
Hi Matt,
While I agree consistency is a good idea, that's apparently not what
the Founding Fathers had in mind. I looked at this Tech Note <http://developer.apple.com/technotes/tn2002/tn2106.html#commands
> which says regarding whose clauses "singular specifiers return bare
values, range and every specifiers return lists."
So whatever is returned from a whose test is based on what is
anticipated by using the "some", "first", or "every" or range
specifier. Therefore, I think iTunes had it correct originally.
But who reads those tech notes anyway?
Cheers,
Doug
--
Doug's AppleScripts for iTunes - http://dougscripts.com
On Aug 2, 2008, at 11:33 AM, Matt Neuburg wrote:
On Thu, 31 Jul 2008 15:03:49 -0400, Doug Adams <email@hidden>
said:
Hello,
I think I have found a rather unusual AppleScript bug (or perhaps
feature; one never knows) in iTunes 7.7.1. It effects several scripts
that may need to reference a track using a persistent ID. When
attempting to reference a single track with a whose clause, the track
reference is returned coerced as a list. This requires that an
additional step be taken to extricate the single item (the track
reference) from the list.
AppleScript's behavior has always been maddening in this regard; for
example, there are lots of things you can ask the Finder where you
don't
know in advance whether you'll get back a single thing or a list,
depending
on whether a single thing or multiple things are being returned.
Therefore
it quite common to coerce the returned value to a list. This
guarantees that
it is a list whether or not it was one to start with (coercing a
list to a
list has no effect, and coercing a single loose thing to a list
turns it to
a list of one item). Now it is possible to proceed with absolute
consistency; you can inquire how many items the list has, etc.
So I would say (1) what you're describing is actually correct
behavior - it
is much more consistent and helpful if the result of a whose inquiry
is a
list, regardless of how many items there are - and (2) you should
have been
using the "as list" trick all along anyway. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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