我试图为我的批量游戏选择使用变量来改变颜色,但它没有改变,这里是与着色相关的所有编码,(抬头) ,它很长,我做错了吗?
:colorchoice1
cls
color 8
set /a %cChoice% = 0
echo so, what color do you want?
echo.
echo 1) black (that'd make it pretty hard to see, huh?)
echo 2) blue
echo 3) green
echo 4) aqua
echo 5) red
echo 6) purple
echo 7) yellow
echo 8) white
echo 9) more options
set /p cChoice=
if %cChoice% == 1 color 0
goto confirmcolor
if %cChoice% == 2 color 1
goto confirmcolor
if %cChoice% == 3 color 2
goto confirmcolor
if %cChoice% == 4 color 3
goto confirmcolor
if %cChoice% == 5 color 4
goto confirmcolor
if %cChoice% == 6 color 5
goto confirmcolor
if %cChoice% == 7 color 6
goto confirmcolor
if %cChoice% == 8 color 7
goto confirmcolor
if %cChoice% == 9 goto colorchoice2
goto colorchoice1
:colorchoice2
cls
color 8
set /a %cChoice% = 0
echo so, what color do you want?
echo.
echo 10) grey (default)
echo 11) light blue
echo 12) light green
echo 13) light aqua
echo 14) light red (pink)
echo 15) light purple
echo 16) light yellow
echo 17) bright white
echo 18) back to other options
我觉得问题已经过了这一点
set /p cChoice=
if %cChoice% == 10 color 8
goto confirmcolor
if %cChoice% == 11 color 9
goto confirmcolor
if %cChoice% == 12 color A
goto confirmcolor
if %cChoice% == 13 color B
goto confirmcolor
if %cChoice% == 14 color C
goto confirmcolor
if %cChoice% == 15 color D
goto confirmcolor
if %cChoice% == 16 color E
goto confirmcolor
if %cChoice% == 17 color F
goto confirmcolor
if %cChoice% == 18 goto colorchoice1
goto colorchoice 2
:confirmcolor
cls
echo are you sure this is the color you want?
echo (remember, this cannot be changed later)
echo.
echo.
echo 1) yes
echo 2) no
set /p confcolor=
if %confcolor% == 1 goto name
if %confcolor% == 2 goto colorchoice1
goto confirmcolor
答案 0 :(得分:2)
您没有使用多行if
语句。现在,您只是告诉if
运行与支票位于同一行的命令。因此,goto confirmcolor
下的if %cChoice% == 1 color 0
命令被称为,无论选择了哪个选项。
有两种方法可以解决这个问题:你可以使用括号来制作这样的多行if
语句:
if %cChoice% == 1 (
color 0
goto confirmcolor
)
if %cChoice% == 2 (
color 1
goto confirmcolor
)
或者,因为这非常多余,您可以在所有检查结束时进行最后一次检查,如下所示:
set /p cChoice=
echo *%cChoice%* selected.
if %cChoice% == 1 color 0
if %cChoice% == 2 color 1
if %cChoice% == 3 color 2
if %cChoice% == 4 color 3
if %cChoice% == 5 color 4
if %cChoice% == 6 color 5
if %cChoice% == 7 color 6
if %cChoice% == 8 color 7
if %cChoice% == 9 goto colorchoice2
if %cChoice% lss 9 goto confirmcolor
goto colorchoice1