Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用数组索引号和choice.exe从编号数组中设置变量_Batch File - Fatal编程技术网

Batch file 使用数组索引号和choice.exe从编号数组中设置变量

Batch file 使用数组索引号和choice.exe从编号数组中设置变量,batch-file,Batch File,我在批处理文件中有许多变量,如下所示: set var1=aaaaa set var2=bbbbb set var3=ccccc set var4=ddddd ... ... set var20=mmmmm choice /c abcd.....p /n /m "your choice" set index=%errorlevel% set newVar=%var%%index% && does not work 如何根据索引数字设置newVar变量的值 通过err

我在批处理文件中有许多变量,如下所示:

set var1=aaaaa 
set var2=bbbbb 
set var3=ccccc 
set var4=ddddd 
...
...
set var20=mmmmm

choice /c abcd.....p /n /m "your choice"
set index=%errorlevel%

set newVar=%var%%index% && does not work
如何根据
索引数字设置
newVar
变量的值 通过
errorlevel
choice
语句中获取该数字

例如:
如果errorlevel为
1
,则newVar的值应为
aaaaaa

如果errorlevel为
2
,则newVar的值应为
bbbbb
,依此类推

choice /c abcd /n /m "your choice"
CALL SET "value=%%var%errorlevel%%%"
ECHO value=%value%

为了方便起见,我将选项减少为a..d。

谢谢,它很有效。因为我需要变量“index”,在程序的后面,我这样修改

choice /c abcd /n /m "your choice"
set index=%errorlevel%
CALL SET "value=%%var%index%%%"
ECHO value=%value%
现在我不知道如何在下面的两列中列出它们

var1=aaaaa var2=bbbb

var3=ccccc var4=dddd

。。。。。 等等。

您应该使用数组