147
Structured Text (ST Language) Specifications
Appendix B
IF A>0 AND B>1 THEN
X:=10; Y:=20;
ELSE
X:=0; Y:=0;
END_IF;
Example 3: If the boolean (BOOL data type) variable A=1(ON), variable X will be substituted with numerical
value 10. If variable A=0(OFF), variable X will be substituted with numerical value 0.
IF A THEN X:=10;
ELSE X:=0;
END_IF;
IF Statement (Multiple Conditions)
Summary
This statement is used to execute an expression when a specified condition is met. If the first condition is not
met, but another condition is met, a corresponding expression is executed. If none of the conditions is met, a
different expression is executed.
Reserved Words
IF, THEN, ELSIF, (ELSE)
Note
ELSE can be omitted.
Statement Syntax
IF
<
condition_1
>
THEN
<
expression_1
>
;
ELSIF
<
condition_2
>
THEN
<
expression_2
>
;
ELSIF
<
condition_3
>
THEN
<
expression_3
>
;
...
ELSIF
<
condition_n
>
THEN
<
expression_n
>
;
ELSE
<
expression_m
>
;
END_IF;
Processing Flow Chart
Usage
Use the IF statement to perform different operations depending which of multiple conditions (
condition
equa-
tion) is met.
Condition 1
Condition 2
Condition 3
False
False
False
True
True
True
Expression 1
Expression 2
Expression 3
Expression m
Содержание CS1-H Series
Страница 3: ...iv...
Страница 5: ...vi...
Страница 7: ...viii TABLE OF CONTENTS...
Страница 15: ...xvi Application Precautions 4...
Страница 151: ...136 Procedures Section 3 2...
Страница 153: ...138 Data Types Appendix A...
Страница 177: ...162 External Variables Appendix C...
Страница 181: ...166 Revision History...