EndLocal in DO Loop

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
Hello,

I have used Endlocal / Setlocal inside a DO loop and it works. I thought that Endloop discards all Variables set since last SetLocal. EndLocal does not discurd the D loop variable:
Code:
SetLocal
Set M=Par is
DO N in /L One Two 3 Four 5 Six
  Echo %M %N
  IF %N == 3  EndLocal
ENDDO
Variable N is alive after IF triggers EndLocal.
This behaviour is usefull in this case but I still wonder why N is alive. N must be special here.

- Heinz Saathoff
 
#3
So it's a kind of implicit SET N=<next> as first command in the loop body.
Just tried UNSET N instead of EndLocal and N is also set at next iteration.
Thanks for clarification

- Heinz