Skip to main content

SA0073: Uses of inadequate counter variable

Detects the use of non-temporary variables in FOR loops.

Justification: This is a performance warning. A counter variable is always initialized each time a POU is called. You can create this variable as a temporary variable (VAR_TEMP). Access to it may be faster and the variable does not take up any permanent memory.

Importance: Medium

PLCopen rule: CP21 / L13

Example 81. Example
PROGRAM PLC_PRG
VAR
    nIndex : INT;
    iVar : INT;
END_VAR
FOR nIndex := INT#0 TO INT#20 BY INT#1 DO
    iVar := iVar + nIndex;
END_FOR

Output under view Messages:

  • sa_icon_message.png SA0073: Counter variable not matching