GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Closing Toolbars by Wildcard


#1

Hi Guys,

I have a need to close several toolbars at once so I am using the code below which works well:

Toolbar "Projects.OAUK" CLOSE
Toolbar "Projects.Flat" CLOSE

In future more toolbars will be added, therefore I would have to add another line(s) to the code as shown below:

Toolbar "Projects.OAUK" CLOSE
Toolbar "Projects.Flat" CLOSE
Toolbar "Projects.ThisProject" CLOSE
Toolbar "Projects.ThatProject" CLOSE

Instead of updating my code every time I add a new toolbar is it possible to add a wildcard command for the toolbars such as:

Toolbar "Projects.*" CLOSE

If not, could such a command be considered?

Regards

Blueroly


#2

A script could get the list of toolbars from DOpus.toolbars and iterate through it, sending a close command for each one as appropriate.


#3

I wouldn't know where to start with scripting but I'll search the forum and see if I can come up with something. Thanks Jon.


#4

A quick snippet to get you started:

function OnClick(clickData) {
    var cmd = clickData.func.command;

    cmd.deselect = false; // Prevent automatic deselection
    cmd.RunCommand('Set UTILITY=otherlog');
    DOpus.ClearOutput;

    for (var eSel = new Enumerator(DOpus.toolbars); !eSel.atEnd(); eSel.moveNext()) {
        DOpus.Output('toolbar: ' + eSel.item());
    }
}

#5

Thanks @lxp, I will try and make sense of it tonight :+1: