SetVar - a script command to set, toggle or delete DO variables from anywhere (buttons, scripts or external applications with dopusrt.exe). It does update buttons as well.
You can use this command to handle global variables in buttons more easily.
Another usecase is to set/delete/toggle variables from external applications, so you can trigger button states and icons or script behaviour from outside of DO.
Features & Params:
SET, set a variable (default operation)
DELETE, delete a variable
TOGGLE, toggle a variables value
EXISTS, check variables existence
NAME, name of the variable
VALUE, value to set (make sure its always the last parameter if used)
PERSIST, switch variable to persistent
NOPERSIST, switch variable to non-persistent
NOCREATE, do not create a variable if it does not yet exist when setting or toggling
NOSET, do not set a value (can be used in conjcuntion with DE/PERSIST e.g.)
TOGGLEHIGH, the “high” value when toggling (default = 1)
TOGGLELOW, the “low” value when toggling (default = 0)
TOGGLEDEL, deletes the variable for “low” toggle state
GLOBAL (use global scope, default)
LISTER (use lister scope)
SOURCE (use source tab scope)
DEST (use destination tab scope)
To set a variable named “MyVar” to “MyValue”:
To set a lister scoped variable named “MyVar” to “MyValue”:
To delete a variable named “MyVar” to “MyValue”:
To toggle a variable named “MyToggle” between the value “0” and “1”:
To toggle a variable named “MyToggle” between the high-value “exists” and always delete the variable if toggle state is low:
To toggle a variable named “MyToggle” between the value “low” and “high”:
To enable persistence of a variable named “MyVar”, without changing its value:
To test for existence of a variable named “MyVar” (returns 0 for “exists” and 1 for “not found”):
(A button script will be stopped if the command is used with EXISTS and the variable does not exist.)
SetVar NAME=MyToggle EXISTS
//works in scripts as well (while not being very handy)
DOpus.Output("Exists: " + DOpus.Create.Command.RunCommand("SetVar NAME=MyVar EXISTS") );
To set a variable named “MyVar” from outside of DO:
Some more sensible combinations are possible, try them for yourself… o)
In case you want to “look” at what happens or just learn how to use it, enable the debug output from the script config section.
To install the command, download the *.js.txt file below and drag it to Preferences / Toolbars / Scripts.
After that the command shall be ready to use in buttons, scripts and externally from dopusrt.exe of course.
Because the scripts filename changed for v0.2:
Remove the former script Command.Generic_SetVariable.js from your /dopusdata/script addins folder!
[ul][li]Latest: v0.2.1 - supports automatic updates/scriptwizard:
Command.Generic_SetVar.js.txt (8.14 KB)
[li]v0.2 - added scope support, command returncodes fixed:
Command.Generic_SetVar.js.txt (7.1 KB)
[li]v0.1 - initial release:
Command.Generic_SetVariable.js.txt (6.45 KB)[/li][/ul]