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


on getCurrentScript (adrtext) {
	<<get script text from message, or selection, and 
		<<(important!) confirm with user
	on confirm (s) {
		loop {
			case dialog.threeWay (s, "Yes", "No", "Why?") {
				3 { <<why?
					dialog.notify ("Scripts have a lot of power. Take a look at the source code of the script first and be sure it's safe to run it. Please be careful.")};
				2 { <<no
					return (false)};
				1 { <<yes
					return (true)}}}};
	local (text = Eudora.getSelectedText ());
	if text == "" { <<nothing selected
		local (x = Eudora.getCurrentMessageObject ());
		text = Eudora.getMessageText (x);
		if text == "" {
			scriptError ("Can't run a script because no message or text is selected. Sorry!")};
		if not confirm ("Run the selected message as a script and put the result on the clipboard?") {
			return (false)}}
	else { <<there is a text selection
		if not confirm ("Run the selected text as a script and put the result on the clipboard?") {
			return (false)}};
	bundle { <<strip out comments
		local (outtext = "", linetext);
		while sizeof (text) > 0 {
			linetext = string.nthField (text, cr, 1);
			text = string.delete (text, 1, sizeof (linetext) + 1);
			if linetext contains "<<" {
				linetext = string.delete (linetext, string.patternMatch ("<<", linetext), infinity)};
			outtext = outtext + linetext + cr};
		text = outtext};
	adrtext^ = text;
	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.