goto-jump destroys for-vars/loop
Posted: 30 Jan 2022 18:32
Code: Select all
@echo off
set List=A B C
for %%L in (%List%) do (
echo outerL=%%L
for %%T in (%%L) do (
echo T > t.log
:Testloop
echo innerL=%%L
if exist t.log (
del t.log
goto :Testloop
)
)
)
p:\> Test.cmd
outerL=A
innerL=A
innerL=%L
p:\>
Solved the real problem by using a recursive procedure instead of "Testloop".
But would to know why the outer for-loop gets canceled after doing one "goto :Testloop"
Thanks a lot in advance