Re: selected items whose class is bookmark item

2007-09-21 Thread J. Stewart
On 9/20/07 at 5:56 PM, Jim DeVona <[EMAIL PROTECTED]> spake thusly:

>> >Is it possible to use a "whose" clause to get only items of a certain
>> >type from a list of Yojimbo database items? Here is an example
>> >intended to get any selected bookmark items:
>...
>> This works for me.
>>
>> --> Cut <--
>> tell application "Yojimbo"
>> set foo to every database item whose class is bookmark item
>> end tell
>> --> Cut <--
>
>Right, same here. However, I'm not after every bookmark item in
>Yojimbo - just the bookmark items in a particular subset of the
>library, such as the list of selected items.


The only way I know of is...

--> Cut <--
set bar to {}
tell application "Yojimbo"
set foo to selection
repeat with anItem in foo
if class of (contents of anItem) is bookmark item then
set end of bar to (contents of anItem)
end if
end repeat
return bar
end tell
--> Cut <--

-- 
Any government big enough to do things for you is big enough to do things to 
you.

--
--
This message is sent to you because you are subscribed to
  the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working
correctly? Please send mail to: <[EMAIL PROTECTED]>


Re: selected items whose class is bookmark item

2007-09-20 Thread Jim DeVona
On 9/20/07, Jim Correia <[EMAIL PROTECTED]> wrote:
> On Sep 20, 2007, at 2:47 PM, Jim DeVona wrote:
>
> > Is it possible to use a "whose" clause to get only items of a certain
> > type from a list of Yojimbo database items?
...
> If you are iterating the list to do work, you could filter the list
> as you go and only perform work on the items with the appropriate
> class.

That was my initial strategy, actually. I was curious if there was
another way to do it, but iterating through the selection isn't a big
problem.

> Or you could write a handler to fetch and filter the selected
> items by class for you. Here's an example:

Hmm. That does look useful. Thanks!

Jim

-- 
--
This message is sent to you because you are subscribed to
  the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working 
correctly? Please send mail to: <[EMAIL PROTECTED]>


Re: selected items whose class is bookmark item

2007-09-20 Thread Jim DeVona
On 9/20/07, J. Stewart <[EMAIL PROTECTED]> wrote:
> On 9/20/07 at 2:47 PM, Jim DeVona <[EMAIL PROTECTED]> spake thusly:
>
> >Is it possible to use a "whose" clause to get only items of a certain
> >type from a list of Yojimbo database items? Here is an example
> >intended to get any selected bookmark items:
...
> This works for me.
>
> --> Cut <--
> tell application "Yojimbo"
> set foo to every database item whose class is bookmark item
> end tell
> --> Cut <--

Right, same here. However, I'm not after every bookmark item in
Yojimbo - just the bookmark items in a particular subset of the
library, such as the list of selected items.

Jim

-- 
--
This message is sent to you because you are subscribed to
  the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working 
correctly? Please send mail to: <[EMAIL PROTECTED]>


Re: selected items whose class is bookmark item

2007-09-20 Thread Jim Correia

On Sep 20, 2007, at 2:47 PM, Jim DeVona wrote:


Is it possible to use a "whose" clause to get only items of a certain
type from a list of Yojimbo database items?


It sounds like an innocently easy question. But I'm afraid there is  
no easy, generally applicable answer.


In the case that you want to access an single item class directly,  
your best bet is to use a whose clause against that item class, such  
as 'every bookmark item whose '.



Here is an example
intended to get any selected bookmark items:

tell application "Yojimbo"

set _items to selected items of browser window 1
if _items is missing value then return

set _bookmarks to every item of _items whose class is bookmark item

end tell

The bookmarks line gives this error: 'Can't get {bookmark item id
"D0303DFD-C8B1-4F17-BD0E-EAD40018D3A1" of application "Yojimbo"} whose
class = bookmark item.' I suspect I am either grossly off track or
nearly there. Any guidance?


The selected items property returns a list of object specifiers. I'm  
not sure there is a good way to filter that list using a whose  
clause. (If there is, someone please clue me in.)


If you are iterating the list to do work, you could filter the list  
as you go and only perform work on the items with the appropriate  
class. Or you could write a handler to fetch and filter the selected  
items by class for you. Here's an example:


on GetSelectedItemsOfClass(zItemClass)
tell application "Yojimbo"
set zSelectedItems to selected items of browser window 1
if zItemClass is database item then
set zFilteredItems to zSelectedItems
else
set zFilteredItems to {}
set zCount to length of zSelectedItems
repeat with i from 1 to zCount
set zItem to item i of zSelectedItems
if class of zItem is zItemClass then
set zFilteredItems to zFilteredItems & 
{zItem}
end if
end repeat
end if
return zFilteredItems
end tell
end GetSelectedItemsOfClass

tell application "Yojimbo"
my GetSelectedItemsOfClass(bookmark item)
end tell


- Jim



--
--
This message is sent to you because you are subscribed to
 the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working 
correctly? Please send mail to: <[EMAIL PROTECTED]>


Re: selected items whose class is bookmark item

2007-09-20 Thread J. Stewart

On 9/20/07 at 2:47 PM, Jim DeVona <[EMAIL PROTECTED]> spake thusly:


Is it possible to use a "whose" clause to get only items of a certain
type from a list of Yojimbo database items? Here is an example
intended to get any selected bookmark items:

tell application "Yojimbo"

set _items to selected items of browser window 1
if _items is missing value then return

set _bookmarks to every item of _items whose class is bookmark item

end tell

The bookmarks line gives this error: 'Can't get {bookmark item id
"D0303DFD-C8B1-4F17-BD0E-EAD40018D3A1" of application "Yojimbo"} whose
class = bookmark item.' I suspect I am either grossly off track or
nearly there. Any guidance?



This works for me.

--> Cut <--
tell application "Yojimbo"
set foo to every database item whose class is bookmark item
end tell
--> Cut <--
--
Under a government which imprisons any unjustly, the true place 
for a just man is also in prison.  -Henry David Thoreau


--
--
This message is sent to you because you are subscribed to
 the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working
correctly? Please send mail to: <[EMAIL PROTECTED]>


selected items whose class is bookmark item

2007-09-20 Thread Jim DeVona
Is it possible to use a "whose" clause to get only items of a certain
type from a list of Yojimbo database items? Here is an example
intended to get any selected bookmark items:

tell application "Yojimbo"

set _items to selected items of browser window 1
if _items is missing value then return

set _bookmarks to every item of _items whose class is bookmark item

end tell

The bookmarks line gives this error: 'Can't get {bookmark item id
"D0303DFD-C8B1-4F17-BD0E-EAD40018D3A1" of application "Yojimbo"} whose
class = bookmark item.' I suspect I am either grossly off track or
nearly there. Any guidance?

Thanks,
Jim

-- 
--
This message is sent to you because you are subscribed to
  the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working 
correctly? Please send mail to: <[EMAIL PROTECTED]>