EasyManua.ls Logo

Omron CX-PROGRAMMER V8.1 - Page 175

Omron CX-PROGRAMMER V8.1
231 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
150
Statement Descriptions Section 5-5
ELSE corresponds to THEN immediately before it, as shown in the above
diagram.
Multiple statements can be executed within expression_1 and
expression_2. Be sure to use a semicolon (;) delimiter between multiple
statements in an expression.
The ELSE statement can be omitted. When ELSE is omitted, no opera-
tion is executed if the result of the condition equation is false.
Processing Flow Diagram
Examples
Example 1: If variable A>0 is true, variable X will be substituted with numerical
value 10. If A>0 is false, variable X will be substituted with numerical value 0.
IF A>0 THEN
X:=10;
ELSE
X:=0;
END_IF;
Example 2: If variable A>0 and variable B>1 are both true, variable X will be
substituted with numerical value 10, and variable Y will be substituted with
numerical value 20. If variable A>0 and variable B>1 are both false, variable X
and variable Y will both be substituted with numerical value 0.
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 corre-
sponding expression is executed. If none of the conditions is met, a different
expression is executed.
Reserved Words
IF, THEN, ELSIF, (ELSE), END_IF
Condition
False
Tr ue
Expression

Table of Contents

Related product manuals