Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

EndLocal in DO Loop

Jul
5
0
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
 
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
 

Similar threads

Back
Top