-1

I have:

setlocal EnableDelayedExpansion
var inLoopVar=hey
var first=!inLoopVar!
echo %!first!%

This outputs ECHO OFF because %!first!% is returned as empty.

How can I print "Hey"

Updated and Clarified:

Here is my full code with comment of what i am trying to do

@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

Instead of ECHO is off. i am trying to output TRUE

Iaim miac
  • 1
  • 2

1 Answers1

0
@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 (
    CALL :sub %%j
)
set /a i=%i%+1
goto loop
GOTO :EOF

:sub
SET "namepart="
FOR %%a IN (%*) DO IF DEFINED namepart (
 SET "Valuepart=!%%a!"
 ECHO !namepart! is !valuepart!
 SET "namepart="
) ELSE (
 SET "namepart=%%a"
)
GOTO :eof

It would help if you would explain what you intend to do rather than set up an inquest to determine what you want to do by examining how you have failed to do whatever it is.

Magoo
  • 77,302
  • 8
  • 62
  • 84