Boolean and Numeric Expressions

<< Click to Display Table of Contents >>

Navigation:  Project > Scripts > ST language > Operators and Expressions in STL >

Boolean and Numeric Expressions

Previous pageReturn to chapter overviewNext page

You can divide expressions into two groups depending on what they yield.

Boolean expressions evaluates to a BOOL type value, TRUE or FALSE.

Here’s an example of a boolean expression:

1 == 1

This expression will evaluate to or yield TRUE(1). A boolean expression could also look like this:

1 > 2

But this time the boolean expression will evaluate to FALSE(0), since 1 is not larger than 2.


Numeric expressions evaluates to an integer or a floating point number.

A numeric expression could look as simple as this one:

13.2 + 19.8

This expression will evaluate to the floating point number 33.0, and therefore is a numeric expression.


Boolean expressions are used in IF statements as conditions. IF the boolean expression evaluates to TRUE, then the following statements will be executed. The TeslaSCADA2 will only execute the statements after the open bracket {, if the expression evaluates to TRUE. This is illustrated by the following example:

A = 0;

IF (A == 0) {  

B = 0;


Line number 3 will only be executed if A is equal to 0. In this case it will. A 0 is assigned to the variable A in a statement right before the IF statement. For now, you’ve seen a simple IF statement, where statements are only executed if an expression is TRUE. If that expression evaluates to FALSE the statements will simply not be executed. What to do if you want to use multiple conditions? Just like most other programming languages you can use the ELSE IF and ELSE keywords for multiple conditions in the same IF statement. Both ELSE IF and ELSE are optional in IF statements, but this is how the syntax looks like:

if (boolean expression) {



else if (boolean expression){


} else {



If the boolean expression on line 1 is FALSE, the statements below will simply not be executed. Instead the compiler will check the boolean expression after the ELSE IF keyword.Here it works just like with the IF keyword: If the boolean expression after the keyword is true, the following statements will be executed.At last is the ELSE keyword. It works as a default option for your IF statement. If all the IF and ELSE IF boolean expressions are evaluated to FALSE, the statements after the ELSE keyword will be executed.


Combining Operators for Advanced Conditions

Beside making multiple conditions you can also expand your conditions to include multiple variables.  You can combine multiple expressions, typically done with a logical operator, to get a larger expression.

What if you want not just 1 but 2 inputs to be TRUE before an output is set. The expression would look like this:

if (INPUT1 & INPUT2) {



Now the expression will evaluate to TRUE, only if INPUT1 and INPUT2 is TRUE.