SA0012: Variable which could be declared as constants

Detects variables that are not accessed with write permission and therefore could be declared as constants

Justification: If a variable is written only at the declaration point and is otherwise used only for reading, then the static analysis assumes that the variable should also not to be changed. Firstly, a declaration as a constant results in checking that the variable is not changed when the program is changed. Secondly, the declaration as a constant may result in faster code.

IMPORTANT:

If multiple applications exist in one project, then only the objects below the currently active application are affected. If there is only one application, then the objects in the common POU pool are also affected.

Importance: Low

Example

PROGRAM PLC_PRG
VAR
        iVar : INT := INT#17;
        iTest : INT;
END_VAR
iTest := iTest + iVar;   // SA0012: iVar could be declared as constant

--> SA0012: Variable 'iVar' könnte als Konstante deklariert werden