问题
Okay, so I'm trying to make a program that "understands" user input and does what they tell it to do. People usually just use specific commands such as "open this file" and it only works if the user types EXACTLY that. I'm trying to give my users a little bit of leeway, so that they can type something like what they want to happen, and the computer will get the general idea. With that block of rambling aside, I've run into a problem.
set word%wordNum%=%word%
:fileExtension
set extChk= %letterNum% - 2 REM Includes the period of the extension
call set extension=%%_albaiRec:~%extChk%,4%%
::extChk is checking for a period so the program will recognize a file extension
set file=
That last line is where I get stuck... I'm trying to use that last recorded word variable.
set var=7
set word7=Wanted text
echo %word%var%%
Sorta like that?
回答1:
Add setLocal enableDelayedExpansion
to the start of your script.
Then replace echo %word%var%%
with echo !word%var%!
.
For more information - http://ss64.com/nt/delayedexpansion.html
来源:https://stackoverflow.com/questions/22621708/how-would-i-call-a-dynamic-variable-name