• 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: Filter reference form question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filter reference form question


  • Subject: Re: Filter reference form question
  • From: Michael Terry <email@hidden>
  • Date: Mon, 19 Apr 2004 22:52:29 -0700

On Dec 17, 2003, at 11:19 AM, Christopher Nebel wrote:

On Dec 17, 2003, at 7:42 AM, Brennan wrote:

I dig the filter reference form, but there's something I'd like to get clear.

In the filter, the 'left hand side' of each boolean clause has the scope of the object being filtered, for example (imaginary terminology)

every foo whose width is 10

... in this case we assume that 'color' is a property of our foo class, so 'width' is evaluated in the scope of each foo object.

Assuming you meant 'width' and not 'color', yes.

OK, all well and good, but what I would dearly love is to also have the
right hand side of the test to operate in the same scope:

every foo whose width is less than its length

This kind of filter fails - apparently, the thing we are comparing it with occurs in a different scope, so even if our foo class has a 'length' property, a 'can't get' error occurs. Apparently 'it' refers to the tell target of the containing object, rather than the one being filtered.

I'm afraid this is impossible... unless someone can enlighten me.

This does seem to be impossible, but not for the reason you suppose. AppleScript parses and sends out the request as you desire -- both "width" and "length" are specified as properties of "the object being examined".

Unfortunately, no application I've checked handles this correctly: the Finder simply errors, and Cocoa applications (I tried TextEdit and Mail) return all elements or none, as if the test were always true or always false. (AppleScript built-in types don't support "whose" in the first place, so the problem is moot -- yes, fixing that is on my to-do list.)

Strictly speaking, this is a bug in the application, though arguably the system should provide more help than it does. I suggest you file a bug against any application that doesn't handle this correctly.


Are there any applications that support this seemingly valid construction? I couldn't get Finder or OmniOutliner to do it.

tell application "Finder"
get every file of item (choose folder) where my test(its name)
end tell

on test(testName)
return testName is "whatever"
end test

For that matter, even this fails in Finder:

tell application "Finder"
get every file of item (choose folder) where true
end tell

... even though any Boolean expression should be valid.


Mike
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Filter reference form question
      • From: Christopher Nebel <email@hidden>
    • Re: Filter reference form question
      • From: Michael Terry <email@hidden>
  • Prev by Date: Re: Determine the version of an application
  • Next by Date: FileMaker Pro & Fax
  • Previous by thread: Re: Out of the stone age
  • Next by thread: Re: Filter reference form question
  • Index(es):
    • Date
    • Thread