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

system.verbs.builtins.Frontier.tools.data.windowTypes.outlinerFile.saveAsPlainText

on saveAsPlainText (adr=nil, adrFilepath=nil) {
	
	if adr == nil {
		adr = window.frontMost ()};
	
	local (f);
	if adrFilepath != nil {
		f = adrFilepath^};
	
	if f == nil { //construct a file path if not specified
		f = Frontier.tools.windowTypes.getDefaultFilename (adr, "txt")};
	
	if not file.putFileDialog ("Save as text:", @f) {
		return (false)};
	
	local (s = string (adr^));
	if system.environment.isWindows { //add linefeeds
		s = string.replaceAll (s, "\r", "\r\n")};
	local (creator = Frontier.id);
	if string.lower (f) endsWith ".py" { //special case for Python scripts
		creator = 'Pyth'};
	
	file.writeWholeFile (f, s, 'TEXT', creator, clock.now ());
	
	if adrFilepath != nil { //tell the caller where the file is -- used for View in Browser
		adrFilepath^ = f};
	
	return (Frontier.tools.windowTypes.commands.open (f));
	
	return (true)}



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.