The syntax of for loop in batch script is as:
for example I want to do something x=6 times
for /l %%a in (1 ,1, 6)
where 1,1,6 means:
- start = 1
- increment per step = 1
- end = 6
Now, I want to know :
Does the start here implies the index and can I keep it 0 also?
If I do the following:
set counter=0 for /l %%a in (0 ,%counter% , 6) do ( GOTO CASE_%counter% :CASE_0 // body :CASE_1 // body ..... :CASE_6 //body GOTO END_SWITCH :END_SWITCH set /A counter=%counter%+1 if %counter% LEQ 6 ( GOTO CASE_%counter% ) ) pause
The above code does not work but if I set counter=1
in the first line in above code it works fine.
So, does it mean that I need to always start my counter from 1? Can I not start it from 0?