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

system.verbs.builtins.radio.file.openWithEditor

on openWithEditor (f, editor=nil) {
	<<Changes
		<<12/13/01; 7:47:28 PM by JES
			<<Created.
			<<Opens a file in the editor configured at user.radio.prefs.editors, for the file's mimetype. If there's no editor for the file, it's an error.
			<<This is a low-level script; if you need to do any user interaction to find an editor, do that in the calling script.
	if editor == nil {
		local (adreditors = @user.radio.prefs.editors);
		local (mimetype = radio.webserver.getFileMimeType (f));
		if not defined (adreditors^.[mimetype]) { //error
			scriptError ("Can't open \"" + file.fileFromPath (f) + "\" for editing because no editor is configured for the type, \"" + mimetype + "\".")};
		editor = adreditors^.[mimetype]};
	local (pc = file.getPathChar ());
	local (appname = file.fileFromPath (editor));
	if appname endswith pc { //apps may be folders on MacOS X
		appname = string.delete (appname, sizeOf (appname), 1)};
	if sys.appIsRunning (appname) {
		if system.environment.isMac {
			required.openDocument (appname, f)}
		else { //windows
			launch.appWithDocument (editor, f)}}
	else { //app not running -- launch app with document
		launch.appWithDocument (editor, f)};
	sys.bringAppToFront (appname);
	return (true)};
bundle { //testing
	openWithEditor (user.radio.prefs.wwwFolder + "#template.txt")}



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.