Download "user manual"
Transcript
PLC
Syntax:
IF <Boolean_Expression1> THEN
<IF_Instruction>
ELSIF <Boolean_Expression2> THEN
<ELSIF_Instruction1>
ELSIF <Boolean_Expression n> THEN
<ELSIF_Instruction n-1>
ELSE
<ELSE_Instruction>}
END_IF;
The part in the curly brackets {} is optional. If <Boolean_Expression1> is TRUE, then only the <IF_Instructions> are
executed and none of the other instructions.. Otherwise, starting with <Boolean_Expression2>, the boolean
expressions are evaluated in sequence until one of the expressions is TRUE. Then, only the expressions following
this boolean expression and before the next ELSE or ELSIF are evaluated. If none of the boolean expressions is
TRUE, only the <ELSE_Instructions> are evaluated.
Example:
IF temp < 17 THEN
Bool1 := TRUE;
ELSE
Bool2 := FALSE;
END_IF;
9.3.2.2.3 CASE
With the CASE instruction, several conditional instructions with the same condition variables can be combined into
a construct.
Syntax:
CASE <Var1> OF
<Value1>: <Instruction 1>
<Value2>: <Instruction 2>
<Value3, Value4, Value5: <Instruction 3>
<Value6 .. Value10 : <Instruction 4>
...
<Value n>: <Instruction n>
ELSE <ELSE-Instruction>
END_CASE;
A CASE instruction is processed according to the following pattern:
•
If the variable in <Var1> has the value <Value i>, the instruction <Instruction i> is executed.
•
If <Var 1> does not have any of the stated values, the <ELSE instruction> is executed.
•
If the same instruction is to be executed for several values of the variable, these values can be written
separately in sequence, separated with commas as the condition of the common instruction.
•
If the same instruction is to be executed for a range of values of the variable, the initial value and the end value
can be written separated by a colon as the condition for the common instruction.
BU 0000 GB
85