beckhoff TE1200 — 4.2.1.4.2 SA0062: Expression is constant

Configuration | Rules 4.2.1.4 SA0061 - SA0080 | SA0061 - SA0080 4.2.1.4.1 SA0061: Unusual operation on pointer | SA0061: Unusual operation on pointer Samples: PROGRAM MAIN VAR pINT : POINTER TO INT; nVar : INT; END_VAR pINT := ADR(nVar); // no error pINT := pINT * DWORD#5; // => SA0061 pINT := pINT / DWORD#2; // => SA0061 pINT := pINT MOD DWORD#3; // => SA0061 pINT := pINT + DWORD#1; // no error pINT := pINT - DWORD#1; // => SA0061 4.2.1.4.2 SA0062: Expression is constant | SA0062: Expression is constant Samples: PROGRAM MAIN VAR bVar1 : BOOL; bVar2 : BOOL; nVar :

INT; END_VAR IF MAX(nVar,1) >= 1 THEN // => SA0062 ; END_IF bVar1 := bVar1 AND NOT TRUE; // => SA0062 bVar2 := bVar1 OR TRUE; // => SA0062 bVar2 := bVar1 OR NOT FALSE; // => SA0062 bVar2 := bVar1 AND FALSE; // => SA0062 IF (bVar1 = FALSE) THEN // => SA0062 ; END_IF IF NOT bVar1 THEN // => no error ; END_IF nVar := 0; IF nVar 0 THEN // => SA0062 ; END_IF TE1200 48 Version: 2.11.1 Function Determines operations on variables of type POINTER TO, which are not = (equality), (inequality), + (addition) or ADR. Reason Pointer arithmetic is generally permitted in TwinCAT and can be used in a meaningful way.

The addition of a pointer with an integer value is therefore classified as a common operation on pointers. This makes it possible to process an array of variable length using a pointer. All other (unusual) operations with pointers are reported with SA0061. Importance High PLCopen rule E2/E3 Function Determines the use of expressions that always have the same value at runtime. Reason A complex expression that is calculated repeatedly and always generates the same value may indicate an error. This applies in particular if something else was intended. In any case, the expression causes an unnecessary load on the runtime. Importance Medium