on readHeadFile (f, adroutline)
local (firstline = true, level, lastlevel)
toys.newObject (outlineType, adroutline)
target.set (adroutline)
edit (adroutline)
file.open (f)
while not file.endOfFile (f)
s = file.readLine (f) - char (10)
if s beginsWith char (26) «end of file
break
if string.lower (s) beginswith ".head"
s = string.delete (s, 1, 6) «pop off the .HEAD
level = ""
while string.isNumeric (s [1])
level = level + string (s [1])
s = string.delete (s, 1, 1)
level = number (level)
s = string.delete (s, 1, 3)
else
level = lastlevel
msg (level + ":" + s)
if firstline
op.setLineText (s)
lastlevel = 0
firstline = false
else
if level > lastlevel
op.insert (s, right)
else
op.go (left, lastlevel - level)
op.insert (s, down)
lastlevel = level
file.close (f)
op.firstSummit ()
window.zoom (adroutline)
window.close (adroutline)
bundle «test code
local (folder = "Macintosh HD:New Releases:ThinkTank Templates:", f)
local (adrtable = @scratchpad.tankTemplates)
toys.newObject (tabletype, adrtable)
edit (adrtable)
fileloop (f in folder)
readHeadFile (f, @adrtable^.[file.fileFromPath (f) - ".TXT"])
window.zoom (adrtable)