<< A script that attempts to create an outline of an HTML document based on the heading tags. This script assumes that the HTML is valid, that heading tags start in column one, and that the headings themselves are simple (e.g., not embedded with anchors, images, etc). This is a good example of how to find all occurrences of a string in a file and then do something with each found occurrence. >> name HTMLOutline; property outopthtml = 1; property outopttext = 2; property outoptscp = 3; property outoptall = 4; sub writeheadingoutline(outputoption, file, headingfile) findResult = true; -- Position at the start of the file file.select(line: 1, column: 1); -- Position caret at 1,1 repeat while findResult findResult = file.find(pattern:""; lines = lines + ""; lines = lines + ""; lines = lines + ("Heading Summary for " + filename); lines = lines + ""; lines = lines + ""; lines = lines + ""; lines = lines + "

"; lines = lines + ("Heading Summary"); lines = lines + "

"; lines = lines + "
";
	lines = lines + "";
	lines = lines + ("For file " + filename);
	lines = lines + "";
	lines = lines + ("Created on " + today.fmtshortdate() + " at " + today.fmtshorttime());
	lines = lines + "";
	lines = lines + "";	

	file.insert(lines);

endsub

sub writepostamble(file)

	lines = {};

	lines = lines + "
"; lines = lines + ""; lines = lines + ""; file.insert(lines); endsub sub createoutline(outputoption) htmlfile = qedit.activefile; if not exists(htmlfile) then result = dialog("There is no document to outline"); else if outputoption = outopthtml or outputoption = outopttext or outputoption = outoptall then headingfile = newfile(); if outputoption = outopthtml or outputoption = outoptall then writepreamble(headingfile, htmlfile.fullfilename); endif writeheadingoutline(outputoption, htmlfile, headingfile); if outputoption = outopthtml or outputoption = outoptall then writepostamble(headingfile); endif else writeheadingoutline(outputoption, htmlfile); endif if outputoption = outoptscp then qedit.showscp = true; endif endif endsub on command "Text" createoutline(outopttext); endon on command "Web Page" createoutline(outopthtml); endon on command "Outline View" createoutline(outoptscp); qedit.showscp = true; endon on command "All" createoutline(outoptall); qedit.showscp = true; endon