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


on displayText (s) {
		<<4/2/07; 11:12:49 AM by DW
			<<Add test code at the end of the script.
		<<1/3/96 DW -- preview a string in web browser
			<<it's really useful for debugging scripts that build HTML text
				<<serialize output file name, so we always get a unique file name
					<<defeats caching, eliminates need to reload
					<<Mon, Apr 29, 1996 at 1:36:49 PM by DW
				<<be sure a web browser is running before displaying the page
	local (folder = webBrowser.getScriptPrefsFolder (), f);
	local (previewname = "Frontier Page Preview");
	fileloop (f in folder) {
		if file.fileFromPath (f) beginsWith previewName {
			file.delete (f)}};
	if not defined (user.webBrowser.webPreviewSerialNumber) {
		user.webBrowser.webPreviewSerialNumber = 1;
		try { // pref location moved from user.prefs
			user.webBrowser.webPreviewSerialNumber = user.prefs.webPreviewSerialNumber;
			delete (@user.prefs.webPreviewSerialNumber)}};
	f = folder + previewName + "." + (user.webBrowser.webPreviewSerialNumber++ + ".html");
	file.writeWholeFile (f, string (s), 'TEXT', user.webBrowser.currentid, ());
	webBrowser.openDocument (f);
	return (true)};
bundle { //test code
	displaytext ("hello world")}

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.