154
Statement Descriptions
Section 5-5
■
Examples
Example 1: If variable A is 1, variable X is substituted with numerical value 1.
If variable A is 2, variable X is substituted with numerical value 2. If variable A
is 3, variable X is substituted with numerical value 3. If neither of these cases
matches, variable Y will be substituted with 0.
CASE A OF
1:X:=1;
2:X:=2;
3:X:=3;
ELSE Y:=0;
END_CASE;
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 vari-
able 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 iteration 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;
Summary of Contents for SYSMAC CX-Programmer 9
Page 2: ......
Page 4: ...iv ...
Page 6: ...vi ...
Page 8: ......
Page 16: ...xvi ...
Page 20: ...xx ...
Page 26: ...xxvi Application Precautions 4 ...
Page 27: ...Part 1 Function Blocks ...
Page 28: ......
Page 154: ...128 Procedures Section 3 2 ...
Page 155: ...Part 2 Structured Text ST ...
Page 156: ......
Page 160: ...134 CX Programmer Specifications Section 4 2 ...
Page 206: ...180 Procedures Section 6 1 ...
Page 208: ...182 System defined external variables supported in function blocks Appendix A ...
Page 230: ...204 Revision History ...
Page 231: ......