Re: whose clause with two conditions?
Re: whose clause with two conditions?
- Subject: Re: whose clause with two conditions?
- From: Christopher Nebel <email@hidden>
- Date: Thu, 25 May 2006 10:19:42 -0700
On May 25, 2006, at 8:07 AM, Björn Lundin wrote:
25 maj 2006 kl. 15.10 skrev Ruth Bygrave:
get (files of folder docfolder whose name extension is "txt") and
(files of folder docfolder whose name extension is "xml")
This, to me, seems impossible. Files rarely end with _BOTH_ txt and
xml
methinks 'or' is better here
That would be wrong for the same reason "and" is wrong, which is that
the values being and-ed (or or-ed) are not Booleans, and what she's
really trying to do is concatenate the lists, which is a job for the
"&" operator. (So you see, "and" was close!)
As Axel pointed out, this sort of thing would be more efficiently
written as
get files of folder docfolder whose name extension is "txt"
or name extension is "xml"
...because that way, you're only making one request to Finder, so it
only has to walk the folders once, not twice. That's the general
structure for multiple tests in a "whose" clause. (Notice that you
have to repeat the "name extension is" part; newbies often try to
write "name extension is foo or bar", which is syntactically valid,
but doesn't work -- that evaluates as "(name extension is foo" [as
boolean]) logical-or (bar [as boolean]".) However, since you're
testing the same property twice, you can save yourself some typing
with this semantically equivalent form:
get files of folder docfolder whose name extension is in
{"txt", "xml"}
...but beware that that structure isn't supported by all applications.
--Chris Nebel
AppleScript Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden