• 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: Filters with "entire contents of"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filters with "entire contents of"


  • Subject: Re: Filters with "entire contents of"
  • From: Michael Terry <email@hidden>
  • Date: Sat, 16 Oct 2004 19:40:14 -0700

On Oct 16, 2004, at 11:30 AM, Michelle Steiner wrote:

But changing it to the following yields the correct result:
(every item of entire contents of f) whose label index is not 0


Wow, that's cool! I spent a fruitless evening some time ago trying to get filter clauses to work with 'entire contents'. Now that I see a working example, it makes perfect sense.


On Oct 16, 2004, at 2:00 PM, Paul Berkowitz wrote:

The construction is similar to the usual

every [element] of [an application object] whose [some property] = [some
value]



unlike all your other examples, but the application object (entire contents
of f) resolves to a list. Here, it's probably implemented as a reference
that stays "live" long enough to have a whose clause act on it. Interesting.

But this still doesn't answer the question of why it works with "every item of" but doesn't work if that is omitted.


set f to choose folder
tell application "Finder"
	(entire contents of f) = (every item of entire contents of f)
end tell

--> true

If they are identical why does the whose clause work with one and not the other?

It's a matter of syntax. 'entire contents' is a property. Using it like this:


entire contents of f

... is syntactically like saying:

name of f

... or

[any property] of f

What you get back in any case is an AppleScript value, plain and simple. In that form, with the property as the first term of the reference, there isn't any case where you're going to be able to apply some filter to it afterwards. I think you're getting tripped up because the meaning of 'entire contents' is obscuring the fact that it won't work the way you wanted as a matter of AppleScript syntax. That's what was happening to me.

A filter, like 'whose label index is not 0' has to be paired up with a plural object specifier, like 'every item' or 'items'. It can't ever be used paired with a property, like 'name' or 'entire contents'.

The way you got it to work, however, is correct syntactically. Here:

(every item of entire contents of f) whose label index is not 0

... you've put 'entire contents' further back in the chain of objects in the specifier. Finder has a chance to return all the object specifiers from 'entire contents' and then hold on to them internally for the next operation: 'every item [of the object specifiers Finder has gathered so far] whose label index is not 0'.

What's strange to me, is that Finder fails in other similar situations. By similar, I mean that it has a chance to return an internal list of object specifiers, and then is asked to apply a filter to them. For example:

tell application "Finder"
get every file of (every folder of (choose folder) where its name is not "nothing") where its name is not "something"
end tell


'(every folder of (choose folder) where its name is not "nothing")' should return a list of object references to Finder, internally, and then it should be able to operate on them with the 'every file where its name is not "something" part. Instead it fails.

I know this sort of thing can work, because it does in other applications, e.g.:

tell application "OmniOutliner" to tell front document
get every row of (every row where its level is 1) where its topic is "test"
end tell


I could have sworn it worked in Finder, too, but I must have just have assumed, since all sorts of other neato object reference forms worked.


Michael

_______________________________________________
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


References: 
 >Re: Filters with "entire contents of" (From: Paul Berkowitz <email@hidden>)
 >Re: Filters with "entire contents of" (From: Michelle Steiner <email@hidden>)

  • Prev by Date: [OT] Mac CAD software
  • Next by Date: Best tool for large (500MB) text manipulation
  • Previous by thread: Re: Filters with "entire contents of"
  • Next by thread: Re: Filters with "entire contents of"
  • Index(es):
    • Date
    • Thread