Operator ‘OR_ELSE’ΒΆ

This operator is an extension of the IEC 61131-3 standard.

The OR_ELSE operator is permitted only for programming in structured text: OR operation of BOOL and BIT operands; with short-circuit evaluation. This means:

When at least one of the operands yields TRUE, the result of the operation also yields TRUE; otherwise FALSE.

In contrast to using the OR IEC operator, for OR_ELSE the expressions on all other operators are not evaluated as soon as one of the operands is evaluated as TRUE.


    bEver: BOOL;
    bX: BOOL;
    dw: DWORD := 16#000000FF;
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; therefore bX is the result of the operation TRUE. However, the expression at the third input is not executed, and bEver remains FALSE. On the other hand, if the standard OR operation was used, bEver would be set to TRUE.

See also