The variable i doesn't get updated properly in each loop step.
Here is a shortened example (first part) and maybe (i'm unsure) a hint to what codepart causes that issue (second part; removed the "set... & part"):
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
set "loadColors=(set "i=0" & (for %%a in (!table!) do (set "c!i!=%%~a" & set /a "i+=1")))"
set loadColors
set /A "x=0, i=0"
set "timestamp="
for /l %%b in (1,1,3000) do if not "!timestamp!" == "!time!" (
set /A "i=(i+1) %% 4, x+=((i-1)>>31)&1"
echo(!i!, !x!
%loadcolors:table=colorTable1%
set "timestamp=!time!"
)
pause
set "loadColors=( (for %%a in (!table!) do (set "c!i!=%%~a" & set /a "i+=1")))"
set loadColors
set /A "x=0, i=0"
set "timestamp="
for /l %%b in (1,1,3000) do if not "!timestamp!" == "!time!" (
set /A "i=(i+1) %% 4, x+=((i-1)>>31)&1"
echo(!i!, !x!
%loadcolors%
set "timestamp=!time!"
)
pause
goto :eof
Code: Select all
loadColors=(set "i=0" & (for %a in () do (set "c=%~a" & set /a "i+=1")))
1, 0
1, 0
1, 0
1, 0
1, 0
1, 0
1, 0
1, 0
1, 0
1, 0
1, 0
1, 0
Drücken Sie eine beliebige Taste . . .
loadColors=( (for %a in () do (set "c0=%~a" & set /a "i+=1")))
1, 0
2, 0
3, 0
0, 1
1, 1
2, 1
3, 1
0, 2
1, 2
2, 2
3, 2
0, 3
1, 3
2, 3
Drücken Sie eine beliebige Taste . . .
(Hope it's not my fever preventing me from finding a solution.)
penpen