简体   繁体   English

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

[英]Goto was unexpected at this time?

I am trying to make a little connect four game and whenever I hit enter without typing anything into the console it says that goto was unexpected at this time All I want it to dos go back to :X for now if there is no user input.我正在尝试制作一个连接四个游戏的小游戏,每当我在没有在控制台中输入任何内容的情况下按 Enter 键时,它都会说此时 goto 是意外的 如果没有用户输入,我希望它现在回到 :X。 Any help would be aappreciated.任何帮助将不胜感激。

: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 .如果您输入带有set/p的字符串,那么就不能说输入的数据不包含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'解决这个问题的方法是"enclose the strings on both sides of the comparison operator in quotes" - 即双引号'not single quotes'

IF syntax is if string1 operator string2 action. IF 语法是 if string1 运算符 string2 操作。

You need你需要

if "%possiblyemptyvariable%"=="1" goto ... 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM