Conditional Statements

<< Click to Display Table of Contents >>

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

Conditional Statements

Previous pageReturn to chapter overviewNext page

The TeslaSCADA2 program is a piece of logic and therefore has to make some decisions. So in your TeslaSCADA2 program you need a way to make decisions. This brings us to conditional statements. Conditional statements are used for exactly that: To make decisions. There are one way of doing conditional statements in Structured Text: IF statement.

 

IF Statements

IF statements are decisions with conditions. There’s a special syntax for IF statements. This means, that you have to write it in a certain way for the compiler to understand it. Because just like semicolons are used to end statements, there are special keywords to make an IF statement. Here’s how the syntax for IF statements looks like in STL for TeslaSCADA2:

if (boolean expression) {

 <statement>;

}

else if (boolean expression){

 <statement>;

} else {

 <statement>;

Statement starts with keyword IF. Then parentheses. Between those two brackets are the condition, which is an expression. But not just any expression. A boolean expression.