后藤这个时候出乎意料了?

2024-01-25

我正在尝试制作一个连接四的小游戏,每当我按下 Enter 键而不在控制台中输入任何内容时,它都会说此时 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

If you are entering a string with a set/p, then there's no saying that the data entered doesn't contain Spaces. The way to get over that is to "enclose the strings on both sides of the comparison operator in quotes" - that is, double-quotes 'not single quotes'

IF 语法是 if string1 运算符 string2 操作。

你需要

if "%possiblyemptyvariable%"=="1" goto ... 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

后藤这个时候出乎意料了? 的相关文章

随机推荐