NoteTaker-GetIndentLevel

This subroutine (and example call), determines the indentation level of a NoteTaker notebook entry. The routine requires two parameters:

  1. A notebook entry reference
  2. The starting indent level. Always 0, in the case of this particular routine.

(A rather obscure tool, I know, but I wrote it out of necessity and anyone scripting AquaMinds’ NoteTaker application should find it useful. NT’s current dictionary does not include an entry indent level property specifically, only ‘has parent’. This is great to a point, but I found it helpful to go a step further.)

OS version: OS X

get_indent_level(entry_reference, 0) 

on get_indent_level(some_entry, theCount)
   tell application "NoteTaker"
      get parent of some_entry
      try
         set xParent to result
      on error
         set xParent to false
      end try
      if xParent = false then
         return theCount
      else
         set theCount to (theCount + 1)
         get_indent_level(xParent, theCount) of me
      end if
   end tell
end get_indent_level