I am sure there is a very simple answer to this, but I have searched and can't find it.
I would like to evaluate a variable using a variable as the variable's name. Clear as mud?
A simple example:
set variable1=hello
set variablename=variable1
echo %%%variablename%%%
The desired result is:
hello
The %%%'s are obviously not correct, but I'm looking to replace the third line with the "magic" that will produce the desired result.
Thanks in advance for any help... and more importantly for fogiving my ignorance and lack of ability to find a solution... it's got to be simple and somewhere on dostips... I just can't figure it out, or find it.
Evaluate Variable
Moderator: DosItHelp
Re: Evaluate Variable
Use either ...
... or ...
Regards
aGerman
Code: Select all
call echo %%%variablename%%%
... or ...
Code: Select all
setlocal EnableDelayedExpansion
echo !%variablename%!
Regards
aGerman
Re: Evaluate Variable
Thank You!
I missed the call on the first and had actually tried the second... without setting EnableDelayedExpansion. Thanks for forgiving my ignorance and helping me out! I much appreciate it!
I missed the call on the first and had actually tried the second... without setting EnableDelayedExpansion. Thanks for forgiving my ignorance and helping me out! I much appreciate it!