SA0072: Invalid uses of counter variable
Detects the use of a counter variable in a FOR loop
Justification: Manipulation of the counter variable in a FOR loop can easily result in an infinite loop. To prevent the execution of the loop for specific values of the counter variable, use CONTINUE or simply an IF.
Importance: High
PLCopen rule: L12
Example 80. Example
PROGRAM PLC_PRG
VAR_TEMP
iIndex : INT;
END_VARFOR iIndex := INT#0 TO INT#20 BY INT#1 DO
iIndex := iIndex - INT#1;
END_FOROutput in the Messages view:
SA0072: Invalid uses of counter variable 'iIndex'