150
Structured Text (ST Language) Specifications
Appendix B
Example 2: If variable A is 1, variable X is substituted with numerical value 1. If variable A is 2 or 5, variable X
is substituted with numerical value 2. If variable A is a value between 6 and 10, variable X is substituted with
numerical value 3. If variable A is 11, 12, or a value between 15 and 20, variable X is substituted with numerical
value 4. If neither of these cases matches, variable Y will be substituted with 0.
CASE A OF
1:X:=1;
2,5:X:=2;
6..10:X:=3;
11,12,15..20:X:=4;
ELSE Y:=0;
END_CASE;
FOR Statement
Summary
This statement is used to execute a specified expression repeatedly until a variable (referred to here as an iter-
ation variable) reaches a specified value.
Reserved Words
FOR, TO, (BY), DO, END_FOR
Note
BY can be omitted.
Statement Syntax
FOR
<
iteration_variable
>
:=
<
initial_value
>
TO
<
final_value_equation
>
BY
<
increment_value_equation
>
DO
<
expression
>
;
END_FOR;
Processing Flow Chart
Usage
Use the FOR statement when the number of iterations has been determined beforehand. FOR is particularly
useful when switching the number of elements in an array variable according to the value of a specified itera-
tion variable.
Iteration variable = Initial
True
False
Expression
End
Iteration
Iteration va Increment value
Iteration
variable
≥
Final value?
Содержание 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...