Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.op.visit
on visit (visitproc) {
local (level = 0); <<callback routine can get level from here
on drivevisit () { <<actually does the traversal, save a parameter and stack space
if not op.go (right, 1) { <<cursor has no subheads, not an error
return (true)};
loop {
local (origcursor = op.getCursor ());
local (nextcursor);
bundle { <<locate the next headline at this level, in case visitproc deletes
if op.go (down, 1) {
nextcursor = op.getCursor ();
op.setCursor (origcursor)}
else {
nextcursor = 0}}; <<this is the last time thru the loop
if not visitproc^ () { <<no param, operation applies to the bar cursor headline
return (false)}; <<unwind recursion
if op.setCursor (origcursor) { <<visitproc didn't delete the cursor
if op.countSubs (1) > 0 { <<has one or more subs at first level
level++; <<this can be referenced by the callback routine
if not drivevisit () { <<recursion returned an error, unwind it
return (false)};
level--}};
if nextcursor == 0 {
return (true)};
op.setCursor (nextcursor)}};
return (drivevisit ())}
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.