我想尝试连接四个游戏,每当我点击进入而没有在控制台中输入任何内容时,它表示此时goto是意外的所有我想要它回到:X现在如果没有用户输入。任何帮助都会受到赞赏。
:X
cls
echo --------------
echo Connect Four X
echo --------------
echo.
echo CHOOSE A COLUMN
echo.
echo.
echo 1 2 3 4 5 6 7
echo.
echo (%a6%) (%b6%) (%c6%) (%d6%) (%e6%) (%f6%) (%g6%)
echo.
echo (%a5%) (%b5%) (%c5%) (%d5%) (%e5%) (%f5%) (%g5%)
echo.
echo (%a4%) (%b4%) (%c4%) (%d4%) (%e4%) (%f4%) (%g4%)
echo.
echo (%a3%) (%b3%) (%c3%) (%d3%) (%e3%) (%f3%) (%g3%)
echo.
echo (%a2%) (%b2%) (%c2%) (%d2%) (%e2%) (%f2%) (%g2%)
echo.
echo (%a1%) (%b1%) (%c1%) (%d1%) (%e1%) (%f1%) (%g1%)
echo.
echo ---------------------------
echo.
echo.
set /p xchoice=:
if %xchoice% == 1 goto xcheck1
if %xchoice% == 2 goto xcheck2
if %xchoice% == 3 goto xcheck3
if %xchoice% == 4 goto xcheck4
if %xchoice% == 5 goto xcheck5
if %xchoice% == 6 goto xcheck6
if %xchoice% == 7 goto xcheck7
goto X
答案 0 :(得分:0)
如果您输入的字符串为set/p
,则不会说输入的数据不包含 Spaces 。克服这个问题的方法是"enclose the strings on both sides of the comparison operator in quotes"
- 即双引号'not single quotes'
IF语法是否为string1 operator string2 action。
你需要
if "%possiblyemptyvariable%"=="1" goto ...