Please enable JavaScript to view this site.

 

Navigation: Macros > Macro Language > Compiler Messages > Errors

Counter variable in FOR loop is already used in another loop

Scroll Prev Up Next More

This compiler error will occur if you use the same counter variable in 2 nested for loops.

 

An example would be:

for nTemp = 1 to 12 step 1
   for nTemp = 1 to 31 step 1 {<- wrong}
      // do something
   endfor
endfor

Note that the counter variable can be reused anywhere else in the macro,

begin   
    for nTemp = 1 to 12 step 1    
        // do something
    endfor
    for nTemp = 1 to 31 step 1   // OK
        // do something else
    endfor
end

but not inside a loop that already uses the same loop counter.

 


Topic 109007, last updated on 18-Apr-2020