• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Descendents in OmniOutliner
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Descendents in OmniOutliner (From: Jeff Porten <email@hidden>)

  • Prev by Date: Re: tell statement changing
  • Next by Date: mail via terminal goes to internal address but not to external address
  • Previous by thread: Descendents in OmniOutliner
  • Next by thread: Logging to terminal
  • Index(es):
    • Date
    • Thread