OR_ELSE
This operator is not specified by the IEC 61131-3 standard. It is only allowed for programming in structured text (ST).
The OR_ELSE
performs an OR-operation of operands of type BOOL and BIT with short-circuiting mode. This has the following effect:
If at least one of the operands is TRUE, then the result of the operation is TRUE, otherwise it is FALSE.
When one operand is TRUE, then the expressions at the other operands are not evaluated (lazy evaluation). In this regard, the OR_ELSE
operator differs from the OR
operator as defined in the standard IEC-61131-3. OR
always evaluates all expressions.
VAR
bEver: BOOL;
bX1: BOOL;
dw: DWORD := 16#000000FF;
END_VAR
bEver := FALSE;
bX := dw.8 OR_ELSE dw.1 OR_ELSE dw.1 OR_ELSE (bEver := TRUE);
dw.8
is FALSE and dw.1
is TRUE, thus the result of the operation (bX
) is TRUE. However, the expression at the third input is not executed, bEver
remains FALSE. If you used the standard OR
operation instead, bEver
were set to TRUE.