- May
- 13,139
- 180
What's going on here?
v:\> type ztest.btm
set a=100
set b=%a
set /a c=%a
set /a d=a
echo %a %b %c %d
v:\> for /l %a in (5,1,6) ztest.btm
5 5 5 100
6 6 6 100
The second and third SET commands, and the ECHO command use the value of "a"
from the FOR loop.
The fourth SET uses the value of "a" set in the batfile.
The same thing happens even after SETLOCAL (which I thought might hide FOR's
counter from the batfile).
v:\> type ztest.btm
setlocal
set a=100
set b=%a
set /a c=%a
set /a d=a
echo %a %b %c %d
v:\> for /l %a in (5,1,6) ztest.btm
5 5 5 100
6 6 6 100
--
- Vince
v:\> type ztest.btm
set a=100
set b=%a
set /a c=%a
set /a d=a
echo %a %b %c %d
v:\> for /l %a in (5,1,6) ztest.btm
5 5 5 100
6 6 6 100
The second and third SET commands, and the ECHO command use the value of "a"
from the FOR loop.
The fourth SET uses the value of "a" set in the batfile.
The same thing happens even after SETLOCAL (which I thought might hide FOR's
counter from the batfile).
v:\> type ztest.btm
setlocal
set a=100
set b=%a
set /a c=%a
set /a d=a
echo %a %b %c %d
v:\> for /l %a in (5,1,6) ztest.btm
5 5 5 100
6 6 6 100
--
- Vince