When can you use the 'whose' clause (Filter)
When can you use the 'whose' clause (Filter)
- Subject: When can you use the 'whose' clause (Filter)
- From: Jerry Krinock <email@hidden>
- Date: Thu, 10 Apr 2008 12:02:16 -0700
In the documentation [1], I read that
"Filter...Specifies all objects in a container that match a condition,
or test, specified by a Boolean expression. The 'filter' form
specifies application objects only. It cannot be used to filter the
AppleScript objects list, record, or text. A term that uses the
filter form is also known as a 'whose' clause."
Firstly, "specifies application objects only" implies that this is for
filtering among applications. There is no use for that, and it does
not make sense. I believe that they meant to say "specifies elements
of application objects, and the immediate children of these elements
only". That seems to be what all the examples do. There is an
example that filters the 'windows' of TextEdit (which are elements of
TextEdit), and another that filters some files from a folder (which
are immediate children of the folder which is an element of Finder).
But it cannot be extended beyond that; see code below [2]. Am I
correct or confused?
Secondly, if this is true, now finally I know why all my attempts to
use a 'whose' clause have never worked! I believe this restriction
should be underlined and in boldface.
Third, it sure would be nice if arbitrary 'list' objects could be
filtered in this way!
Jerry Krinock
[1] http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_reference_forms.html#/
/apple_ref/doc/uid/TP40000983-CH4g-120522
[2]
-- This works:
local myHome
tell application "Finder"
set myHome to item 1 of (folders whose name is "jk") in folder
"JMiniHD:Users"
end tell
-- And this works:
local myHome
tell application "Finder"
set myLib to item 1 of ((folders whose name is "Library") in folder
"JMiniHD:Users:jk")
end tell
-- But this fails:
local nonLibFolders
tell application "Finder"
set myLib to item 1 of ((folders whose name is "Library") in myHome)
end tell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden