IF instruction
With the IF instruction you can check a condition and, depending upon this condition, execute instructions.
Syntax:
IF <Boolean_printout1> THEN
<IF_instructions>
{ELSIF <Boolean_printout2> THEN
<ELSIF_instructions1>
.
.
ELSIF <Boolean_printout n> THEN
<ELSIF_instructions n-1>
ELSE
<ELSE_instructions>}
END_IF;
The part in braces {} is optional.
If the <Boolean_printout1> returns TRUE, then only the <IF_Instructions> are executed and none of the other instructions. Otherwise the Boolean expressions, beginning with <Boolean_printout2>, are evaluated one after the other until one of the expressions returns TRUE. Then only those instructions after this Boolean expression and be-fore the next ELSE or ELSIF are evaluated. If none of the Boolean expressions produce TRUE, then only the <ELSE_instructions> are evaluated.
Sample:
IF temp<17
THEN heating_on := TRUE;
ELSE heating_on := FALSE;
END_IF;
Here the heating is turned on when the temperature sinks below 17 degrees. Otherwise it remains off.