Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.op.readHeadFile
on readHeadFile (f, adroutline) { <<New in 5.0 -- reads files created by Ready! and ThinkTank <<A way of closing a loop. I wrote both those products in the mid-80s. <<Now we're coming back to the PC, makes sense to offer a path forward. <<http://www.scripting.com/fatpages/97/07/dotHeadFormat.html local (firstline = true, level, lastlevel); new (outlineType, adroutline); target.set (adroutline); <<edit (adroutline) file.open (f); msg (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 = "C:\\Frontier 5\\ThinkTank Templates\\", f) <<local (adrtable = @scratchpad.tankTemplates) <<new (tabletype, adrtable) <<fileloop (f in folder) <<readHeadFile (f, @adrtable^.[file.fileFromPath (f) - ".TXT"]) <<window.zoom (adrtable) <<edit (adrtable)
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.