Global Variables Tool


A Global variable management tool created mainly for the fun of it and to try out some different aspects of Directory Opus scripting. (@wowbagger has a perfectly good global variable management dialog here: Global Variable Management Dialog). Only string, number and boolean variables are available for creation and editing.

The script adds a new command to Directory Opus (GlobalVariables) which you can assign to a toolbar button, hotkey or menu item. There are no additional arguments for this command, it just opens the dialog.


  • Download: (Requires DOpus 12.21) Global Variables.js.txt (23.7 KB)

  • Drag the .js.txt file to Preferences / Toolbars / Scripts.


  • 1.0 (3/5/20)
    • Initial Release.
  • 1.0.1 (3/5/20)
    • Double-clicking a variable opens the edit dialog.
    • Various tweaks to dialogs.
  • 1.0.2 (1/6/20)
    • Added config option to choose whether dialog remembers last size/position.
    • Fixed crash caused when global variables contained a vector.
  • 1.0.3 (3/6/20)
    • Fixed: Crash caused when global variables contained a Map object.
  • 1.0.4 (22/6/20)
    • Added: Now shows Vector and Map variables as disabled items in the list.
  • 1.0.5 (6/2/22)
    • Modified by @tbone to allow for "unknown" variable types.


Once the dialog opens you will see a list of all the currently defined global variables. Each variable will show its current value, type and whether it's persistent or not. At the top of the dialog is an edit box which allows you to filter the list of variables - simply start typing and the list will update. Clicking the Clear Filter button will reset this filter. There's a second button at the top, Refresh, which will re-read the list of variables.

At the bottom of the dialog is a New... button which will open a dialog allowing you to create a new variable:


From this dialog you can define the name, value, type and persistence of the new variable. Click Apply to create the variable. This dialog will sightly change when you select different variable types, hiding sections that are irrelevant to the selected type.

All variables in the main dialog have a checkbox, if any variables are checked the Edit... and Delete buttons become available. You can double-click a variable in the list to edit it (ignoring all checked items). The Edit... button will show the same dialog as the New... button and you will be able to edit all 'checked' variables. If only one variable was checked then you can edit the name and the current value, type and persistence will reflect that variable, if multiple variables were checked then the name is no longer editable , the value, type and persistence will not reflect any selected variable, and the editing you do will modify all of the checked variables. Note: There is no undo so be careful.

Vector and Map variables, although they are included in the list, are not editable.

Right clicking a variable in the main dialog will show a popup menu:


From this menu you can Edit... the item under the mouse pointer, again using the same edit variable dialog but this time ignoring checked items. Two options allow you to Copy Name or Copy Value to the clipboard. Other options in this menu are self explanatory.

If you right click in the list but not over a variable (ie, in an empty area of the list) a similar popup menu will appear but most options will be unavailable and the Edit... option will change to a New... option which will operate identically to the New... button described above.


Looks good, thanks for sharing.

1 Like

It gives me the error:
Global Variables: Error on line 205, position 9
Global Variables: Invalid argument or procedure call (0x800a0005)

Not at the computer at the moment - so I cant see the line number it is referring to.

What were you doing at the time and what version of DOpus are you running?

Hi, thanks for the reply. I'm on v12.20.6
Not doing something especifically . The error appears every time I push the included button.

Will check when I get back to the computer .

I can't reproduce this - no matter what I try. It works fine on 12.20.6 here. Is the script showing up as installed correctly in Preferences / Toolbars / Scripts?

Same here. I did a bit of scratching around and the trigger appears to be an existing global variable which is a vector object. If this is not enough information for you to debug I can send you the script I used to create the vector object GV that triggers the error for me.

Thanks. Would save me some time if you could send the variable that triggers it please.

Sample sent via PM.

1 Like

Thanks guys. The script was never intended to handle vector variables but it wasn't correctly ignoring them. It should be ok now. :crossed_fingers:

Thanks @Steve, however I still getting an error at line 222.
A quick workaround, althought not the best that I do was:

if (String(dlg.Control("listVariables").GetItemByName(strName).subitems(0))=="")

before line 222.

Can you send me your uservars.oxc file please.

Sure. Send you already. I noticed there's indeed some issues with vectors and maps variables, however I don't get any value from the other variables.

Thanks for sending that. I've just uploaded 1.0.3 which works with your variables. :smiley:

Yep. Now it works as intended. Many thanks

1 Like
  • 1.0.4 (22/6/20)
    • Added: Now shows Vector and Map variables as disabled items in the list.

Hi Steve,

I was tinkering with javascript objects in DOs VARs collection (DOpus.Vars e.g.), and noticed that DO does weird things if you try to create/assign a javascript object to a VAR. It will render as "unknown" in most of the cases, but not in all. While investigating I tried your tool to get a glance and it had problems with my global variables as well, it crashed. o) It did not expect variables of type "unknown". I added support for that with only some minor changes and upped the version to v1.0.5, maybe you would like to put it into the opening post.

Global Variables.js_v1.05.txt (23.7 KB)

I just added support for "unknown" when populating the list and made sure these are exclusive conditions, to not run into the "catch anything else-"condition/block at the bottom when dealing with "unknown" types. Also added "[...]" and "{...}" as value place holder for vector/maps, it seems a common thing, not sure you like it.

Thank you for this! o)

Thanks @tbone. I've modified the root post to incorporate 1.0.5. I don't have easy access to a Windows machine at the moment so I will take your word for it that it works :smiley:

1 Like