Spork Software
Better than a
poke in the eye
with a sharp stick.

Constructs and Subroutines

NoteTaker - Get Indent Level | Application: AquaMinds' NoteTaker

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.

get_indent_level(entry_reference, 0)

on get_indent_level(some_entry, theCount)
tell application "NoteTaker"
get parent of some_entry
set xParent to result
on error
set xParent to false
end try
if xParent = false then
return theCount
set theCount to (theCount + 1)
get_indent_level(xParent, theCount) of me
end if
end tell
end get_indent_level
Vanilla AppleScript - Clean String | Application: n/a

This subroutine takes a string of text and replaces all occurrences of certain characters and replaces them with another character. Routine requires three parameters:
  1. The original string you wish to clean.
  2. A list of strings you wish to find in the string. (Get rid of)
  3. A new character to put in their place. (In the example below, I'm using an empty string "", meaning the bad characters are simply taken out.)

set dirty_string to "some_bad?#strinGwith*^-!invalid/Chars"

clean_chars(dirty_string, {"?", "#", "*", "^", "!", "/", "-", "_"}, "") of me

on clean_chars(origString, listOfBadChars, replChar)
repeat with s in listOfBadChars
set AppleScript's text item delimiters to s
set string_list to every text item in origString
set AppleScript's text item delimiters to replChar
set origString to every item in string_list as string
end repeat
return origString
end clean_chars

2004 Spork Software | Made on a Mac | Hosted by fluid:dt