AppleScript: Using "whose" with record values does not work

416 views Asked by At

In my scriptable app, one of the properties is of a named record type, and that record type has been declared in the sdef as well (named "custom record").

I can get the record like this:

get owner of anElement
    --> {pool:"test", position:2}

I can also successfully test for it like this:

set target to {pool:"test", position:2}
if owner of anElement = target then
    -- found!

But I cannot use it in a whose clause:

get allElements whose owner = target
    --> {}

I also cannot use missing value in the test:

get allElements whose owner = missing value
    --> error number -1700 from missing value to custom record

Is that expected behavior with AppleScript, i.e. is it unable to handle records in whose clauses?

Or am I doing something wrong? I have so far not implemented any coercion handlers nor special record handlers because nothing has indicated that I'd need them.

Also, please see my related question: Cocoa Scripting: Returning "null" vs. "missing value"

1

There are 1 answers

8
vadian On

Short answer : It's expected behavior.

The whose clause works only for element reference types (classes which have an object specifier), but not for record types and custom lists.

Even the selection property of the Finder cannot be filtered by a whose clause.