Monday, November 08, 2010 at 12:00 AM.

system.verbs.apps.AnArchie.utilities.organizeOutline

on organizeOutline (outlineAddr) {
	local (summitText);
	
	<<move the cursor to the first real processable line
	target.set(outlineAddr);
	op.firstsummit();
	summitText = op.getLineText();
	op.go(right,1);
	op.sort(); << sort it to make sure things are pre-ordered for scanning
	
	local(curLine, nextLine, dir, matchCount, atEnd = false);
	loop {
		on processLine(testLine, addHeading) {
			nextLine = op.getLineText();
			if (testLine == nextLine) { << we found a match
				matchCount++;
				addIt = false;
				if (addHeading) {
					op.go(up, 2); << move to last non-match line
					if (op.getLineText() == summitText) { << first item was match
						dir = right};
					op.insert(testLine + " +", dir);
					op.go(down, 1);
					op.reorg(right, 1);
					op.go(flatdown,1)};
				op.reorg(right,1);
				if (op.go(flatdown, 1)) {
					return(true)}
				else {
					atEnd = true;
					return(false)}} << no more entries!
			else {
				return(false)}};
		dir = down;
		matchCount = 0;
		curLine = op.getLineText();
		if (op.go(down, 1)) {
			addIt = true;
			loop {
				if (!processLine(curLine, addIt)) {
					if (matchCount > 0) {
						matchCount++; << adjust for initial find
						if (!atEnd) { <<Êwe need to be a bit smarter on the last entry
							op.go(flatup, matchCount+1)} << adjust for header
						else {
							op.go(flatup, matchCount)};
						op.setLineText(curLine + " ["+string(matchCount)+"]");
						op.collapse()}; << makes things cleaner
					break}}}
		else {
			break}};
	target.clear()};

<<organizeOutline(@system.verbs.apps.anarchie.searchResultsTst)



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.