此时,后藤出乎意料了吗? [英] Goto was unexpected at this time?

查看:78
本文介绍了此时,后藤出乎意料了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行一点四连环游戏,每当我按Enter键而没有在控制台中键入任何内容时,它都说goto此时是意外的,如果没有,我现在想要的所有操作都将返回:X.用户输入.任何帮助将不胜感激.

 :Xcls回声--------------回声连接四个X回声--------------回声.回声选择一个列回声.回声.回声1 2 3 4 5 6 7回声.回声(%a6%)(%b6%)(%c6%)(%d6%)(%e6%)(%f6%)(%g6%)回声.回声(%a5%)(%b5%)(%c5%)(%d5%)(%e5%)(%f5%)(%g5%)回声.回声(%a4%)(%b4%)(%c4%)(%d4%)(%e4%)(%f4%)(%g4%)回声.回声(%a3%)(%b3%)(%c3%)(%d3%)(%e3%)(%f3%)(%g3%)回声.回声(%a2%)(%b2%)(%c2%)(%d2%)(%e2%)(%f2%)(%g2%)回声.回声(%a1%)(%b1%)(%c1%)(%d1%)(%e1%)(%f1%)(%g1%)回声.回声---------------------------回声.回声.设置/p xchoice =:如果%xchoice%== 1转到xcheck1如果%xchoice%== 2转到xcheck2如果%xchoice%== 3转到xcheck3如果%xchoice%== 4转到xcheck4如果%xchoice%== 5转到xcheck5如果%xchoice%== 6转到xcheck6如果%xchoice%== 7转到xcheck7转到X 

解决方案

如果您输入的是带有 set/p 的字符串,则无需说输入的数据不包含空格.解决该问题的方法是将比较运算符两边的字符串都用引号引起来" -即,将双引号'不是单引号'

IF语法是string1运算符string2操作.

您需要

 如果%possibleemptyvariable%" =="1"转到... 

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. 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. 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 syntax is if string1 operator string2 action.

You need

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

这篇关于此时,后藤出乎意料了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆