<< Click to Display Table of Contents >> Navigation: »No topics above this level« IF statement |
mapp Services V5.16
The IF statement can be used to execute certain statements depending on a condition.
IF <expression1> THEN
<statement_list1>
ELSIF <expression2> THEN
<statement_list2>
.
.
ELSIF <expressionN> THEN
<statement_listN>
ELSE
<statement_list>
END_IF;
An IF statement is executed as shown below:
•If the expression in <expression1> returns TRUE, then only the <statement_list1> statements and no others are executed.
•Otherwise, the expressions beginning with <expression2> are evaluated in order until one of them returns TRUE. Then the statements following this expression and before the next ELSE or ELSIF are executed.
•If none of the expressions return TRUE, then only the statements between ELSE and END_IF are executed.
ELSIF sections are optional.
The ELSE section is optional. If none of the expressions are TRUE and the ELSE section is missing, then no statements are executed.
IF Var1 < 10 THEN
Var2 := 1;
ELSE
Var2 := 2;
END_IF;
If the value of "Var1" is less than 10, "Var2" is assigned the value 1; otherwise, "Var2" is assigned the value 2.