A community of Frontier
and Radio Users


Meridian News


Community List


Regex Project

Here's another useful little tool I keep in my custom menu. It copies scripts and outlines to the clipboard, and maintains their formatting by indenting with spaces.

It's intended for use with email. If you just copy a script, and then paste it into a text window like an email client's, you'll get the curly braces and semicolons that make it hard to read. This script avoids that problem, and it's very fast.

local (oldTarget, txt)
try
  case typeOf (window.frontMost ()^)
    outlineType
    menubarType
    scriptType
      oldTarget = target.set (window.frontMost ())
  else
    return (false)
else
  return (false)
op.setDisplay (false)
local (oldCursor = op.getCursor (), indent = 2)
op.firstSummit ()
op.fullExpand ()
on add (s)
  txt = txt + string.filledString (' ', (op.level () - 1) * indent) + s + cr
loop
  add (op.getLineText ())
  if not op.go (flatdown, 1) {break}
clipboard.putvalue (txt)
op.setCursor (oldCursor)
op.setDisplay (true)
target.set (oldTarget)