• 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: whose clause with two conditions?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: whose clause with two conditions?
      • From: Ruth Bygrave <email@hidden>
References: 
 >whose clause with two conditions? (From: Ruth Bygrave <email@hidden>)
 >Re: whose clause with two conditions? (From: Björn Lundin <email@hidden>)

  • Prev by Date: Re: Suppress dialog box
  • Next by Date: Re: Exiting a repeat loop if not false
  • Previous by thread: Re: whose clause with two conditions?
  • Next by thread: Re: whose clause with two conditions?
  • Index(es):
    • Date
    • Thread