Configuration | Rules IF (nFlags AND E_State.eUnknown) DWORD#0 THEN // no error nState := nState AND E_State.eUnknown; // no error ELSIF (nFlags OR E_State.eStopped) DWORD#0 THEN // no error nState := nState OR E_State.eRunning; // no error END_IF 4.2.1.3.16 SA0059: Comparison operations always returning TRUE or FALSE | SA0059: Comparison operations always returning TRUE or FALSE Samples: PROGRAM MAIN VAR nBYTE : BYTE; nWORD : WORD; nDWORD : DWORD; nLWORD : LWORD; nUSINT : USINT; nUINT : UINT; nUDINT : UDINT; nULINT : ULINT; nSINT : SINT; nINT : INT; nDINT : DINT; nLINT : LINT; bResult :
BOOL; END_VAR bResult := nBYTE SA0059 bResult := nBYTE SA0059 bResult := nWORD SA0059 bResult := nDWORD SA0059 bResult := nLWORD SA0059 bResult := nUSINT SA0059 bResult := nUINT SA0059 bResult := nUDINT SA0059 bResult := nULINT SA0059 bResult := nSINT >= -128; // => SA0059 bResult := nSINT >= SINT#-128; // => SA0059 bResult := nINT >= INT#-32768; // => SA0059 bResult := nDINT >= DINT#-2147483648; // => SA0059 bResult := nLINT >= LINT#-9223372036854775808; // => SA0059 4.2.1.3.17 SA0060: Zero used as invalid operand | SA0060: Zero used as invalid operand Samples: PROGRAM MAIN VAR nBYTE : BYTE; nWORD : WORD; nDWORD : DWORD; nLWORD :
LWORD; END_VAR nBYTE := nBYTE + 0; // => SA0060 nWORD := nWORD - WORD#0; // => SA0060 nDWORD := nDWORD * DWORD#0; // => SA0060 nLWORD := nLWORD / 0; // Compile error: Division by zero TE1200 47 Version: 2.11.1 Function Determines comparisons with literals whose result is always TRUE or FALSE and which can already be evaluated during compilation. Reason An operation that consistently returns TRUE or FALSE is an indication of a programming error. Importance High Function Determines operations in which an operand with value 0 results in an invalid or meaningless operation. Reason Such an expression may indicate a programming error. In any case, it causes unnecessary runtime. Importance Medium