为什么一定要用call,call 后的set 语句为什么一定要用两个%%
@echo off
setlocal enabledelayedexpansion
for /f %%n in (test.txt) do (
set /a i+=1
set gn!i!=%%n
)
set gn
pause
for /l %%j in (1,1,%i%) do call :rec %%j
pause
goto :eof
:rec
setlocal
call set tmp=%%gn%1%%
set /a sum+=tmp
set /a lvl+=1
if %lvl% gtr 1 (
set exp=%exp%+%tmp%
set /a idx+=1
echo !idx!:!exp!=%sum%
) else (set exp=%tmp%)
set /a nxt=%1+1
for /l %%j in (%nxt%,1,%i%) do call :rec %%j
endlocal & set idx=%idx%
goto :eof
@echo off
setlocal enabledelayedexpansion
for /f %%n in (test.txt) do (
set /a i+=1
set gn!i!=%%n
)
set gn
pause
for /l %%j in (1,1,%i%) do call :rec %%j
pause
goto :eof
:rec
setlocal
call set tmp=%%gn%1%%
set /a sum+=tmp
set /a lvl+=1
if %lvl% gtr 1 (
set exp=%exp%+%tmp%
set /a idx+=1
echo !idx!:!exp!=%sum%
) else (set exp=%tmp%)
set /a nxt=%1+1
for /l %%j in (%nxt%,1,%i%) do call :rec %%j
endlocal & set idx=%idx%
goto :eof
