View Single Post
Hi Rob,

Thanks for the quick response. I'd considered following the ancestors and children to print the hierarchy, but I think there is a problem with that approach.

Since I'm not very familiar with Apple Script I may be missing this in your code, but how do you deal with the possibility that within a reasonably complex hierarchy several rows matching the search query will be returned. If you print each one, you'd get multiple duplications of hierarchy. For example, let's make my previous outline a bit more complex:

1. Top topic
1.1 Foo | Andy
1.2 Bar | Joe
2. Second topic <-- Common ancestor of both of the tasks for Bob
2.1 foobar | Bob <-- First task for Bob
2.1.1 abc
2.2 blah | Robin
2.3 blah blah
2.3.1 blah blah blah
2.3.2 blah blah 123 | Bob <-- Another task to be done by Bob

What I want to print is:

2. Second topic
2.1 foobar | Bob
2.1.1 abc
2.3 blah blah <-- Notice I skipped 2.2 altogether
2.3.1 blah blah blah
2.3.2 blah blah 123 | Bob

Is this case covered by the code you've provided? I tried running one of your posted filtering scripts yesterday but it does not appear to handles the situation correctly either (http://forums.omnigroup.com/showthread.php?t=16392). The new document just contains a flat list of rows.

I can't think of a clean way to handle this other than just managing the tree of objects myself in Python (which I have working, but it's slow and queries are not as powerful as if I'd let OmniOutliner process them directly).

This all reminds me of another question... is there a way to tell what type of object you're dealing with in Apple Script? I'm building a tree but the very first node is actually a document. So I manually set the top-level item to not be a "row", but it seems there should be a way to query objects directly to identify the type. One idea we had (since we're programming in Python) is something like:

def calc_is_row(o):
return o.__repr__().find('row') != -1

Basically, just look at the string representation of the object-type and if it contains the word "row", it is a row.

Thanks,

JL