Attention

IronPLC implements many parts of the IEC 61131-3 standard and is working toward full Structured Text support. Key features still missing include ranges, enum and I/O mapping.

P2035

Code

P2035

Message

Ordering comparison on reference types (only = and <> are allowed)

This error occurs when ordering comparison operators (<, >, <=, >=) are used with reference types. Only equality (=) and inequality (<>) comparisons are allowed on references.

Example

The following code will generate error P2035:

PROGRAM Main
    VAR
        x : INT;
        xRef : REF_TO INT := REF(x);
        yRef : REF_TO INT := REF(x);
        result : BOOL;
    END_VAR

    result := xRef > yRef;  (* Error: ordering comparison on references *)
END_PROGRAM

To fix this error, use equality or inequality comparison instead:

PROGRAM Main
    VAR
        x : INT;
        xRef : REF_TO INT := REF(x);
        yRef : REF_TO INT := REF(x);
        result : BOOL;
    END_VAR

    result := xRef = yRef;  (* Correct: equality comparison is allowed *)
END_PROGRAM