Why doesn't this work?
@echo off
for /l %%i in (0, 1, 100) do (
for /l %%j in (0, 1, 10) do (
set /a curr=%%i*10 + %%j
echo %curr%
)
echo "-----------------------------"
)
This is the output I get from this:
1010
1010
1010
1010
1010
1010
1010
1010
1010
1010
1010
"----------------------------"
1010
1010
1010
1010
1010
1010
1010
1010
...
It seems like it precomputes the math before executing, so that when it does finally execute, %curr%
is already at 1010. How do I keep it from doing that? I'm trying to get output like this:
0
1
2
3
4
5
6
7
8
9
10
"----------------------------"
11
12
...
Thanks in advance
Answer from Johannes Rössel (for those who might look for it later):
@echo off
setlocal enabledelayedexpansion enableextensions
for /l %%i in (0, 1, 100) do (
for /l %%j in (0, 1, 10) do (
set /a curr=%%i*10+%%j
echo !curr!
)
echo "-----------------------------"
)