Scripting Cheat Sheet V6

Navigation:  Widget Designer > Script Language >

Scripting Cheat Sheet V6

prev main next

Navigation:  Widget Designer > Script Language >

Scripting Cheat Sheet V6

prev main next

Loading...

The Scripting Cheat is primarily meant for all programmers that are familiar with the Widget Designer scripting language. Click here to download the sheet as a pdf file.

Local variables

Using the "var" keyword variables can be defined that only exist within the scope (e.g. script or block) where they were defined. The variable's type is automatically determined by evaluating the assigned default value.

 
var x = "This is a string."

var y = 23

Literals

Anything that declares a literal expression (i.e. is not a number, command, function, variable…) must be enclosed in double quotation marks.

 
var myText = "Hello, world!"

var myNumber = 1.23

Parameters

Command parameters must be enclosed in round brackets. Advantage: parameters can be nested, i.e. a parameter can contain a function that has its own set of parameters.

 
WDLabelText(1, "Hello, again!")

WDLabelText(1,
Round(Fader1.Value, 2))

Object Notation

Commands that apply to a widget can also be called using "object notation", i.e. by specifying the object and method.

Not just widgets, but practically all items have methods or properties (depending on their type) that can be accessed using the object notation.

 
WDFaderGoDown(1, 10)
Fader1.GoDown(10)

label1.Text="abCDEfgh"
var z = Label1.text
var x = z.SubString(2,3)

DebugMessage(x, x.Length)

Expressions

Mathematical expressions (formerly requiring the "Math" keyword) are now accessible as global functions.

 
DebugMessage(Acos(0.5))

Conditions

Conditions can be combined (using "and"/"or"), nested and are not "space sensitive" anymore.

 
If x = 1 and (a="A" or b="B") {
 DebugMessage("Ok")
 }

If Else

All code blocks are now enclosed in curly brackets. These can be at the end of a line or the beginning of the next one.

"If" can now be followed by any number of "ElseIf" statements and one "Else".

 
If x=1 {
 DebugMessage("x is 1") }
ElseIf x=2 {
 DebugMessage("x is 2") }
Else {
 DebugMessage("x is " + x)
}

Select is now Switch

The former "Select" command was renamed to "Switch".

 
Switch x {
 Case 1
   DebugMessage("x is 1")
 Case 2
   DebugMessage("x is 2")
 Case Else
   DebugMessage("x is " + x)
}

For Loops

Loops implemented with "For" now define the loop-variable and can optionally contain a "Step" parameter.

 
For i = 10 To 2 Step -1 {
 DebugMessage(i)
}

ForEach Loops

This command loops through a list.

Define a loop variable and specify the list to loop through.

In each iteration "item" will hold a member from the list "list".

var list = [1,7.2,true, "PandorasBox"]

ForEach item in list {
 DebugMessage(item)
}

Result:

1

7.2

true

PandorasBox