Re: whose clause with two conditions?
Re: whose clause with two conditions?
- Subject: Re: whose clause with two conditions?
- From: Ruth Bygrave <email@hidden>
- Date: Fri, 26 May 2006 07:33:36 +0100
On 25 May 2006, at 18:19, Christopher Nebel wrote:
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.
That's really informative--I now understand what I was doing wrong
(logical and vs concatenate lists). It also makes clear that when I
was putting the word 'whose' in twice in an attempt to give it enough
context, I should have just put the bit _after_ the 'whose'...
Thank you,
Ruth Bygrave
_______________________________________________
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