Mathematical Expressions

Navigation:  Widget Designer > Scripting > Script Language >

Mathematical Expressions

prev main next

Navigation:  Widget Designer > Scripting > Script Language >

Mathematical Expressions

prev main next

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

When working with variables, you sometimes need to assign its value directly, but other times you might also want to recalculate your variable and use it for other mathematical calculations. You can achieve this with special commands, or with a very easy to understand mathematical syntax.

Obviously, the variable must be of the type integer or double to allow mathematical operations. Integers are rounded to the according whole number. However there is one exception to this rule. Adding letters is actually possible and equals appending letters.
Array variables are supported too. You call an index with square brackets: Variable[Index].

First, the below examples for a relative value assignment work in direct and in common commands. They offer five basic arithmetical operations: addition, subtraction, multiplication, division and exponentiation. The value itself can be a number you choose, another Variable, or a Member Value.

wd_math-expressions_1

For more complex operations, you can use mathematical syntax as you would write it, see some examples below, for var1 = 5 and var2 = 11.
Remember to assign a suiting type to the variable for the result, e.g. Integer.

Syntax

Result

varRes = calculation

varRes = var1 + var2

 

varRes = var1 - 10

 

varRes = var1 * var2 * 2

 

varRes = 45 / var1

 

varRes = var1 ^4

 

16

 

5

 

110

 

9

 

625

For more sopisticated mathematical functions, like sinus, logarithms or modulo, please also refer to the chapter Math Object. This object provides several members for further mathematical operations.

 

Conditions

If you use those conditions outside of an if-statement, it will return a Boolean value.
Normal condition statements like "is bigger as?" or "equals?" can be combined with AND or OR statements. Please note that those two expressions are not case sensitive.

 

Description and Syntax

Result

Checks if value 1 is bigger than value 2

varRes = (3 > 4)

 

 

Checks if value 1 is bigger than or equals value 2

varRes = (3 >= 3)

 

 

Checks if value 1 is smaller than value 2

varRes = (3 < 4)

 

 

Checks if value 1 is smaller than or equals value 2

varRes = (4 <= 4)

 

 

Checks if value 1 equals value 2

varRes = (3 = 4)

 

 

Checks if value one does not equal value 2

varRes = (3 != 4)

 

False

 

 

 

 

True

 

 

 

True

 

 

 

 

True

 

 

 

False

 

 

 

True

Checks if ALL conditions are true

varRes = ((3 < 4) AND (3*2 = 6))

varRes = ((3 < 4) AND (3*5 = 7))

varRes = ((3 > 4) AND (3*5 = 7))

 

 

Checks if AT LEAST ONE condition is true

varRes = ((3 < 4) OR (3*5 = 15))

varRes = ((3 < 4) OR (3*5 = 7))

varRes = ((3 > 4) OR (3*5 = 7))

 

 

True

False

False

 

 

 

True

True

False