Chapter 8. Structured Text (ST) Programming
374
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C
8.2.4
IF Statement
The IF construct offers conditional execution of a statement list. The condition is determined by
result of a Boolean expression. The IF construct includes two optional parts, ELSE and ELSIF, that
provide conditional execution of alternate statement list(s). One ELSE and any number of ELSIF
sections are allowed per IF construct.
Format
IF BooleanExpression1 THEN
StatementList1;
[ELSIF BooleanExpression2 THEN (*Optional*)
StatementList2;]
[ELSE
(*Optional*)
StatementList3;]
END_IF;
Where:
BooleanExpression
Any expression that resolves to a Boolean value.
StatementList
Any set of structured text statements.
Note:
Either ELSIF or ELSEIF can be used for the else if clause in an IF statement.
Operation
The following sequence of evaluation occurs if both optional parts are present:
■
If BooleanExpression1 is TRUE (1), StatementList1 is executed. Program execution continues
with the statement following the END_IF keyword.
■
If BooleanExpression1 is FALSE (0) and BooleanExpression2 is TRUE (1), StatmentList2 is
executed. Program execution continues with the statement following the END_IF keyword.
■
If both Boolean expressions are FALSE (0), StatmentList3 is executed. Program execution
continues with the statement following the END_IF keyword.
If an optional part is not present, program execution continues with the statement following the
END_IF keyword.
Example
The following code fragment puts text into the variable Status, depending on the value of I/O point
input value.
IF Input01 < 10.0 THEN
Status := Low_Limit_Warning;
ELSIF Input02 > 90.0 THEN
Status := Upper_Limit_Warning;
ELSE
Status := Limits_OK;
END_IF;
Summary of Contents for PACSystems RSTi-EP
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...