Build items for context menu dynamically from script?

I wonder, whether it would be possible to build a context menu dynamically from the contents of the selected XML file by parsing its nodes.

In my case, the XML file is an Apache Ant build file, whose <target> element's @name attribute I read into an array. This gives me something like ["default","init","clean","mkdirs","release","etc."], which represents the list of build targets. A Build menu's sub items would be built from this array. Each of the items would then run Apache Ant with the selected target passed to it.

I have written a little script, that does exactly this, up to the results of my DOM parsing. Now, that I have the array ready, I don't know how to continue. First I'd need to setup a context menu for this filetype. Let's call it Build. It contains a row of sub menu items, the topmost being the one, that gets executed as default, which simply would build the whole package, but beneath this, a single target could be chosen, selecting one would simply issue a DOS command ant <targetname>.

The question now is: can I create the sub items of a menu dynamically from a script, each time I open it?
The result then would look something like this:

  Build (default)


Not directly, at least currently.

Indirectly, you could use Go FOLDERCONTENT to display a menu of commands/shortcuts placed in a folder somewhere, which the script generated.

You could also have the script generate the actual toolbar XML data, but I wouldn't generally recommend that.

Ah, the beauty of XML! I may try this. Have to check, what is faster. An XSL-Transform or a DOM build.
But then, how would I apply that toolbar data? A pointer to the right chapter in the docs (dynamically loading toolbar data or so) would be fully sufficient.

Any special reason?

You can use the Toolbar command to tell Opus to open and close toolbars. Type /buttons to go to the folder they are stored in.

I guess there isn't a strong reason not to use that method, other than it being a bit fiddly to generate the right XML, or the chance we might change the format (but we'd need to be able to load old toolbars, so it should still work).

Cool, thanks.