Script Language

Navigation:  Widget Designer > Scripting >

Script Language

prev main next

Navigation:  Widget Designer > Scripting >

Script Language

prev main next

Please wait. Due to its content this page might take a while to load...

The built-in script language allows you to create customized routines of commands. Currently over 1500 commands are available to control specific features of Pandoras Box, Widget Designer or other 3rd party products and protocols.

Commands can be used as a project's Start-up Script or in some nodes, tools and many widgets. For example, you may assign one or more commands to a button click.

How to enter a command using Script Assistant

In order to use a command, open the widget's Item properties, for example from a Custom Script Button.

As soon as you start typing in the dedicated script text field, the feature Script Assistant will automatically search for available commands that contain the typed characters and display the result in a list box. The [ESC] key hides this list. The availability of commands depends also on the fact, whether a widget is already added to the project, i.e. without existing faders, the Script Assistant will not offer fader commands.

You have three possibilities for setting up the script filter of your assistant, just right-click in your script field and choose one of the following filter styles:

- Starts with expression
The Script Assistant will show only entries that start with the entered expression. This is useful if you are already familiar with the command structure and know which group of commands you need.

- Contains expression (this is default)
You do not need to know how exactly the command starts, typing "fader" will suggest "WDFader..." too. Type more characters to shorten the list or use the arrow keys (up and down) to select a command from it and press carriage return.

- Camel Case
This is the fastest way of getting the correct command if you already know which command you want to use. This filter type requires deep knowledge of the command structure, as you only type in the letters that are written with capitals in the command (this way of writing with capitals inside an expression is called "camel case").
e.g.: type in "wdfd" and the command "WDFaderDown" will appear in the list box.

If you have one preferred filter style, you can set it up in your User Profile as the default value.

Now, the placeholders need to be filled with concrete information, e.g. a numeric ID for a certain element that you would like to control or send values to. In addition you may use variables. Again, the Script Assistant offers a drop-down with all available variables.
The Script Assistant will guide you through the arguments, too, by listing all arguments and their respective data types (like, String, Integer, Bool, ...)

Please note that all literal values, meaning any kind of character string, has to be enclosed in either single or double quotation marks. If one of those is part of your string, just use the other one for declaring the literal. Do not use accents like ´ or `!
WDLabelText(1,'Hello World!')
WDLabelText(2,"Hello World!")
WDLabelText(3,'Hello "World"!')
Some strings, like Pandoras Box device parameters or variable names, already appear at the Script assistant with quotation marks. You can select one of those without adding anything and proceed with the next argument. If you like to use a variable's value, type the variable name without quotation marks.

All commands affecting a widget are available with the object and member notation, too.

Multiple commands (i.e. one script) can be executed by delimiting every command with a carriage return at the end of each command, simply hit the "enter" key. To delete a command, select it and press the "Delete" key.

Command examples

For example, to set the opacity of Layer 1 on Server 1 to 128 you will need the following command:
DeviceSetParam(SiteID,DeviceID,ParamName,AbsoluteValue)

Since this is only a template of the command, you will need to enter the numeric values for the SiteID, DeviceID, AbsoluteValue and the ParamName as plain text.
The correct command for this example would be written like this:
DeviceSetParam(1,1,"Opacity",128)

Alternatively you may enter a variable name for any placeholder. Assuming you have an integer variable defined with the name varNumber and the value of 1, you could write the command as follows:
DeviceSetParam(varNumber,varNumber,"Opacity",128)

Advanced script techniques

Normally, you would enter a command and then fill out the placeholders (also called the "arguments" of a command). But there is also a technique that allows more direct programming. Still the syntax must conform, but as it is more open it can be used more flexible. You have direct script access to Variables and certain member values including nodes. This allows direct value assignment and item control. For further information and examples click the according links.

direct command

corresponding common command

Variables

 

Variable = Value
varNumber = 123
ListVariable[Index] = Value
varList[5] = 123

VValue(VarName,Value)
VValue(varNumber,123)
VSetArrayValue(VarName,Index,Value)

VSetArrayValue("varList",5,123)

Members

 

MemberID.MemberValue = Value
label1.text = "Hello"
 
fader2.value = 123
fader2.value = varNumber

WDLabelText(ID,Text)
WDLabelText(1,"Hello")
WDFaderValue(ID,Value)
WDFaderValue(2,123)
WDFaderValue(2,varNumber)

Nodes

 

NodeID.Nodecommand
node1.ResetPlaylist
node2.PowerOn

 

The last row mentions Node Commands. They cannot only access functions of a node but also the parameters. Please see the according chapter for more details.

Of course, mathematical functions can be applied to values and variables, too. Please refer to the chapter Mathematical expressions and conditions for more information.
Since Version 6, it is even possible to use mathematical expressions as command arguments or programming statements, e.g.:
DeviceSetParam(varNumber,varNumber+10,"Opacity",128)
If  varRes >= (varNumber*5) {True Script}

Useful Tools from the Context Menu

wd_scripting-context-menuWhen you right-click somewhere inside a scripting field, the context menu opens up and offers you some practical items:

Test: Executes the whole script inside this field

Test selected Lines: Executes all highlighted lines or the line in which the cursor is located

Find... : Searches for the highlighted expression (only text search)

Find references: Searches for the highlighted expression (searches for references to the marked object)

Find next  / previous: Goes through all found expressions

Go to definition...: Shows the origin of the object, i.e. the line where a local variable is initialized, the variable list if the object is a global variable, or it opens the function / macro editor if the object is one of those.

Automatically show Assistant: Uncheck this if you do not need the Script Assistant

Filter Style: Select the Script Assistant's filter style which is described above

Test Debugging: Enables the Debug Logger for the "Test" function mentioned above and clears it if necessary

Enable Debug Logging: Uncheck this if you do not want the Debug Logger to open

Open Debug Logger: This opens the dialog Debug Logger

Always show errors / warnings: Per default, the Debug Logger does not open automatically to show whether a script includes an error. It opens only if you choose the "Test"command from the right-click menu. If you like to always see errors and warnings, enable this option.

More information

WD commands can be written in upper or lower case style or mixed, with one exception:
Wherever you need to specify text-based parameters such as Opacity, the entry is case sensitive and must not have additional blanks (space characters).
Please see the next page for a list with all parameter names from Pandoras Box. Then, a Command List explains all available commands.
Advanced users can merge commands in functions and macros or combine them with If-queries and for loops repetitions as explained in the topic programming statements.