Modifying a counted DO loop's counter?

May 20, 2008
12,335
134
Syracuse, NY, USA
The help says a counter DO loop sets an environment variable to the value of it's counter. Maybe so, but it doesn't use the current value of that environment variable when iterating. Below I'd expect to see just 1. But
Code:
v:\> type dotest.btm
do i=1 to 3
        echo %i
        set i=%@eval[%i+10]
enddo

v:\> dotest.btm
1
2
3

It would be quite useful to be able to jump ahead (maybe even backward) in a counted DO loop.
 
WAD; and it's always worked this way.

Each time through the loop, the counter is reset to the previous value + or - the increment / decrement value.

IMO, if you want to randomly change the counter you're using the wrong DO syntax - you should be doing a DO UNTIL or DO WHILE.
 

Similar threads