AND_THEN

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

The operator AND_THEN is only allowed for programming in Structured Text with the following operation: AND operation of operands of type BOOL and BIT, with short-circuit evaluation. This means:

If all operands are TRUE, the result of the operation is also TRUE, otherwise it is FALSE.

But: TwinCAT also executes the expressions for other operands only if the first operand of the AND_THEN operator is TRUE. In conditions such as IF (ptr < > 0 AND_THEN ptr ^ = 99) THEN..., this can avoid problems with null pointers.

In contrast, TwinCAT always evaluates all operands if the IEC operator AND is used.

See also: