I have a batch file in which I need to use a variable inside a variable's name. In case that doesn't make sense, here's an example: @echo off set FirstVariable=1 set SecondVariable=2 set ThirdVariable=3 set /p choose=Which variable: rem On previous line, user would input First, Second, or Third. rem The next line is where I am having difficulty. set /a final=34 + %%choose%Variable% echo final pause>nul exitI need a sum of an integer and that.... thing.
Any advice?
@echo off & setlocal EnableDelayedExpansion
set FirstVariable=1
set SecondVariable=2
set ThirdVariable=3
set /p choose=Which variable:
rem On previous line, user would input First, Second, or Third.
rem The next line is where I am having difficulty.
set /a final=34 + !%choose%Variable!
echo %final%
pause>nul
exit
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |