我有:
setlocal EnableDelayedExpansion
var inLoopVar=hey
var first=!inLoopVar!
echo %!first!%
这输出ECHO OFF
因为%!first!%
返回为空。
如何打印“嘿”
更新和澄清:
这是我的完整代码,并评论了我正在尝试做的事情
@ECHO OFF
setlocal EnableDelayedExpansion
set RESULT=TRUE
set INPUT[0]=+NAME=RESULT; VARB=Second; VARC=Second; VARD=Second; VARE=Second; VARF=Second; VARG=Second;
set length=1
set i=0
:loop
if %i% equ %length% goto :eof
for /f "usebackq delims=+ tokens=2" %%j in (`set INPUT[%i%]`) do (
set y=%%j
FOR /f "tokens=1-7 delims=; " %%a IN ("!y!") DO (
set aaa=%%a
set testVar=!aaa:~5!
REM basically testVar resolves to RESULT
echo !!testVar!!
REM Above echo prints "RESULT"
echo %!!testVar!!%
REM Above echo prints "ECHO is off."
)
)
set /a i=%i%+1
goto loop
而不是ECHO is off.
我试图输出TRUE