Monday, November 08, 2010 at 12:02 AM.
system.verbs.builtins.export.sendSubMenu
on sendSubMenu () {
local (adrMenuBar = address (window.frontmost ()));
local (fname = op.getLineText () + " SubMenuBar");
if not file.putFileDialog ("Name of export file:", @fname) {
return (false)};
local (subMenu);
bundle { <<create a menubar object in subMenu, containing the selection
wp.setTextMode (false); <<be sure copy gets outline stuff
editMenu.copy ();
new (menubarType, @subMenu);
target.set (@subMenu);
editMenu.paste ();
op.firstSummit (); <<put cursor on blank line
op.deleteLine (); <<delete it
target.clear ()};
bundle { <<create the new file, the importer script is embedded in it
export.sendtodesktop (@export.callImportSubMenu, fname)};
bundle { <<save the submenu into a 'data' resource
local (resdata, cmdName);
pack (subMenu, @resdata);
pack (resdata, @resdata);
rez.putNamedResource (fname, 'data', string (adrMenuBar), @resdata)};
bundle { <<for the future, get the name of the parent menu in a 'STR ' resource
local (parent, saveCursor);
op.setDisplay (false);
saveCursor = op.getCursor ();
if op.go (left, 1) {
parent = op.getLineText ()}
else {
parent = ""};
op.setCursor (saveCursor);
op.setDisplay (true);
rez.putStringResource (fname, 132, parent)};
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.