Re: Descendents in OmniOutliner
Re: Descendents in OmniOutliner
- Subject: Re: Descendents in OmniOutliner
- From: Adam Wuellner <email@hidden>
- Date: Thu, 28 Apr 2005 09:50:49 -0500
On 4/27/05, Jeff Porten <email@hidden> wrote:
> Seeing as how there's an "ancestor" class, I'm guessing there's a
> simple answer to this: anyone know how to get all of the descendants of
> a row in OmniOutliner 3?
Well, there's a 'child' class, too; plural 'children'. That'll get
you one level deep.
Here was a quick attempt at recursively plumbing the depths of an
outline. Don't laugh. ;-)
It'll give you a list like this:
{
{
child 1 of (first selected row of front document),
{}
},
{
child 2 of (first selected row of front document),
{}
},
{
child 3 of (first selected row of front document),
{}
},
{
child 4 of (first selected row of front document),
{}
},
{
child 5 of (first selected row of front document),
{
{
child 1 of child 5 of (first selected row of front document),
{}
}
}
},
{
child 6 of (first selected row of front document),
{
{
child 1 of child 6 of (first selected row of front document),
{}
},
{
child 2 of child 6 of (first selected row of front document),
{}
},
{
child 3 of child 6 of (first selected row of front document),
{}
}
}
},
{
child 7 of (first selected row of front document),
{
{
child 1 of child 7 of (first selected row of front document),
{}
},
{
child 2 of child 7 of (first selected row of front document),
{}
}
}
}
}
So, it gets them all, but I think there's too many curly braces in the
result. Maybe not. You get a list of lists. Each sub list is a list
with the child as the first element, and a list of its children as the
second element, which in turn....
--script start
tell front document of application "OmniOutliner Professional"
my getAllKids(first item of selected rows)
end tell
on getChildren(theRow)
tell application "OmniOutliner Professional"
return theRow's children
end tell
end getChildren
on getAllKids(theRow)
local myKids
set myKids to my getChildren(theRow)
repeat with i from 1 to count of myKids
set item i of myKids to {item i of myKids, my getAllKids(item i of myKids)}
end repeat
return myKids
end getAllKids
--script end
HTH,
Adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden