Omron NJ-series User Manual page 279

Machine automation controller cpu unit software
Hide thumbs Also See for NJ-series:
Table of Contents

Advertisement

6 Programming
Application:
Use this construct to perform different actions based on the value of an integer.
Description:
If <integer_expression> matches <integer_expression_value_n>, <statement_n> is executed.
If <integer_expression> does not match any of the integer values, <statement_m> is executed.
Precautions:
• CASE must always be used together with END_CASE.
• Use one of the following for the <integer_expression>:
• An integer or enumeration variable (example: abc)
• An integer expression (example abc+def)
• A function that returns an integer value (example: xyz())
• You can write any of the statements on multiple lines. Separate statements with a semicolon (;).
• To specify OR logic of multiple integers for <integer_expression_value_n>, separate the values
with commas. To specify a continuous range of integers, separate the start integer and the end
integer with two periods (..).
Example 1:
CASE A OF
ELSE
END_CASE;
CASE A OF
ELSE
END_CASE;
Example 2:
• Example for an Integer Enumeration Variable
CASE ColorVar OF
RED:
BLUE:
ELSE
END_CASE;
6-92
You can specify a condition for a specific integer value, or the same condition for
multiple integer values.
1: X:=1;
2: X:=2;
3: X:=3;
X:=0;
1: X:=1;
2,5: X:=2;
6..10: X:=3;
11,12,15..20: X:=4;
X:=0;
You can give an integer variable, integer expression, integer function return value,
enumeration
variable,
<integer_expression>. An example is shown below.
X := 0;
X := 1;
X := 2;
A value of 1 is assigned to variable X when variable A is 1.
A value of 2 is assigned to variable X when variable A is 2.
A value of 3 is assigned to variable X when variable A is 3.
If none of the values is matched, a value of 0 is assigned to
the variable X.
A value of 1 is assigned to variable X when variable A is 1.
A value of 2 is assigned to variable X when variable A is 2 or 5.
A value of 3 is assigned to variable X when variable A is between 6 and 10.
A value of 4 is assigned to variable X when variable A is 11, 12,
or between 15 and 20.
If none of the values is matched, a value of 0 is assigned to the
variable X.
or
enumeration
function
NJ-series CPU Unit Software User's Manual (W501)
return
value
for
the

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents