Can a custom menu be activated from within a procedure

Procedure windows have no Action menu item. Is it possible to set up a custom menu which can be selected from within a procedure? I’ve tried, using

filemenubar ..., menu(...) + menuitem(...)

and it doesn’t work. I suspect it may not be possible.

It’s not documented, but if you set the third parameter of the filemenubar statement to "PROCEDURE_MENUBAR", you can completely change the menus in a procedure window (in fact, this is how Panorama X sets up the menus in the first place. Here is the code that would set up the standard procedure window menus.

filemenubar "",standardfilemenu(
    "Export"+tab()+"(Export)","="+menuitem("Export","enabled",false()),
    "Import"+tab()+"(Import)","="+menuitem("Import","enabled",false()),
    "Preview","="+menuitem("Preview","enabled",false()),
    "Preview One Record","="+menuitem("Preview One Record","enabled",false()),
    "Print One Record","="+menuitem("Print One Record…","enabled",false())
)+
standardeditmenu()+
standardviewmenu()+
menu("Source")+
    menuitem("Shift Selection Left","ACTION","unindentSelection:","KEY","[")+
    menuitem("Shift Selection Right","ACTION","indentSelection:","KEY","]")+
    menuitem("Comment/Uncomment","ACTION","toggleCommentForSelection:","KEY","/")+
menu("Mark")+
    menuitem("Add Mark","CODE","insertnewproceduremark")+
    menuseparator()+
    arraymenuitems(tagarray(info("proceduretext"),"//[--","--]",cr()),"CODE",{proceduresearchexact "//[--"+|||«»|||+"--]" if error beep stop endif})+
menu("Program")+
    menuitem("Run","ACTION","toolRun:","KEY","R")+
    menuitem("Single Step","ACTION","toolSingleStep:","KEY","D")+
    menuseparator()+
    menuitem("Check Procedure","ACTION","toolCheckProcedure:","KEY","1")+
    menuseparator()+
    menuitem("Dialog Workshop…","CODE",{openwizard "Dialog Workshop"})+
"","PROCEDURE_MENUBAR"

Be careful – if you mess this up you might not be able to edit procedures any more in this database! Also, the code above is still undocumented even though I am posting it here, and it could (probably will) change in future releases.

Wow - that looks scary - I think I’ll look for a safer approach to my problem.