-1
我有:變量名 - 批次
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
將'var'更改爲'set'。然後從最後一行刪除'!'或'%'。 – Compo
@Compo,我更新了問題以澄清。謝謝! –