Re: When can you use the 'whose' clause (Filter)
Re: When can you use the 'whose' clause (Filter)
- Subject: Re: When can you use the 'whose' clause (Filter)
- From: "Stockly, Ed" <email@hidden>
- Date: Thu, 10 Apr 2008 19:34:48 -0700
- Thread-topic: When can you use the 'whose' clause (Filter)
>>>Jerry > 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.
"Application Objects" refers to objects that belong to applications. In the
case of the Finder it includes folders and files and windows etc.
>>> I believe that they meant to say "specifies elements of application
objects, and the immediate children of these elements only".
No, that's not the case. Whose clauses are implemented by application
developers. Some developers may choose to implement them in a more limited
way than others, but some allow a wide range of elements to be addressed by
whose clauses.
>>>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?
Confused. I think the syntax of your commands may be throwing you off.
Try running this:
---------
tell application "Finder"
set myHome to folder 1 of (folders whose name is "jk") in folder
"Jaguar:Users:"
end tell
tell application "Finder"
set myLib to folder 1 of folder "Jaguar:Users:jk:" whose name is
"Library"
end tell
tell application "Finder"
set myLib to folder 1 of myHome whose name is "Library"
end tell
--and this
tell application "Finder" to set myFolders to every folder of entire
contents of myHome whose name contains "E"
>>> 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.
That's not why, the restriction is not in the whose clause, it may be in the
way your scripts are specifying objects.
>> Third, it sure would be nice if arbitrary 'list' objects could be filtered in
this way!
No argument there. You may try looking at the free list and record OSAX from
Late Night Software.
>> local myHome
FYI, you don't need to declare local variables. The only AppleScript
context where I believe that's useful is when you're debugging with
ScriptDebugger and you're in a handler.
>> set myLib to item 1 of ((folders whose name is "Library") in myHome)
I believe the problem here is not the whose clause, but the specifier for
the object referred to in the variable myHome.
As long as that is a valid Finder object it should work.
Try inserting these commands before the one that generates the errors:
Log myHome
Log class of myHome
Open the log when you run the script in script editor and see what those
are.
>> set myLib to item 1 of ((folders whose name is "Library") in myHome)
You can also try breaking the command into its components:
Set myLib to Folder "Library" of myHome
Set HomesFolders to folders of myHome
HTH,
ES
_______________________________________________
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