question on "global" FOR variables.
Posted: 28 Jul 2016 17:32
This is from the help output of "for /?"
Can anyone explain what this means in practice? For example running the following code using %%a in consecutive loops seems to cause no issues but the "GLOBAL" part of the helpfile leads me to believe that I should only be able to have one active "%%a" variable at a time:Output:
Code: Select all
Remember, FOR variables are single-letter, case sensitive, global,
and you can't have more than 52 total active at any one time.
Can anyone explain what this means in practice? For example running the following code using %%a in consecutive loops seems to cause no issues but the "GLOBAL" part of the helpfile leads me to believe that I should only be able to have one active "%%a" variable at a time:
Code: Select all
for %%a in (1, 2) do ((@ECHO a1: %%a) &(CALL :mysub) &(@ECHO a1: %%a))
GOTO:EOF
:mysub
for %%a in (3,4) do (@ECHO a2: "%%a")
GOTO:EOF
Code: Select all
a1: 1
a2: "3"
a2: "4"
a1: 1
a1: 2
a2: "3"
a2: "4"
a1: 2