Monday, November 08, 2010 at 12:03 AM.
system.verbs.builtins.html.menu.insertMacro
on insertMacro (macroName, prompt=nil) {
local (macroData = "", s);
local (macroStart = "{" + macroName + " (\"");
local (start, end);
wp.setTextMode (true);
wp.getSelect (@start, @end);
if prompt != nil {
if start != end { //Text is selected
macroData = wp.getSelText ()}
else {
if not (dialog.ask (prompt, @macroData)) {
return (false)}};
s = macroStart + macroData + "\")}";
wp.insert (s);
wp.setSelect (start + sizeOf (macroStart), start + sizeOf (macroStart) + sizeOf (macroData))}
else { //this is a macro with no parameters
s = "{" + macroName + " ()}";
wp.insert (s);
wp.setSelect (start + sizeOf (s), start + sizeOf (s))};
window.update (window.frontmost ())}
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.