Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Unary NOT Used With an Unsupported Operand Type

The NOT operator is valid for boolean, integer and bit-oriented operands. Other types, such as structs, arrays and strings, are not supported.

Erroneous code example:

TYPE Wrapper : STRUCT
    out : BOOL;
END_STRUCT
END_TYPE

PROGRAM mainProg
VAR
    value : Wrapper;
END_VAR
    value := NOT value;
END_PROGRAM

To fix this, apply NOT to the actual scalar field instead:

TYPE Wrapper : STRUCT
    out : BOOL;
END_STRUCT
END_TYPE

PROGRAM mainProg
VAR
    value : Wrapper;
END_VAR
    value.out := NOT value.out;
END_PROGRAM