Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 编写一个批处理游戏,关于使用GOTO标签_Batch File_Goto - Fatal编程技术网

Batch file 编写一个批处理游戏,关于使用GOTO标签

Batch file 编写一个批处理游戏,关于使用GOTO标签,batch-file,goto,Batch File,Goto,当用户从中键入“1”时,我使用此(测试)代码: @echo off :gotoONE echo ONE :BeginCode set /p Choice=What is your choice? if '%choice%' == '1' GOTO gotoONE if '%choice%' == '2' GOTO gotoTWO :gotoTWO echo TWO 代码将转到“gotoTWO”而不是“gotoONE” 如何使代码转到“gotoONE”而不是向前移动。如果输入了其他内容,则进行此

当用户从中键入“1”时,我使用此(测试)代码:

@echo off
:gotoONE
echo ONE
:BeginCode
set /p Choice=What is your choice?
if '%choice%' == '1' GOTO gotoONE
if '%choice%' == '2' GOTO gotoTWO
:gotoTWO
echo TWO
代码将转到“gotoTWO”而不是“gotoONE”


如何使代码转到“gotoONE”而不是向前移动。

如果输入了其他内容,则进行此更改以防止代码丢失

if '%choice%' == '1' GOTO gotoONE

如果您尝试在set/p Choice=之后使用它来代替原始命令集,它应该可以正常工作。

Wild guess:选项开头的大写字母?您的意思是我应该将其设置为小写?您的代码可以正常工作,如前所述。当然,如果包含任何空格等,它将失败。输入
1
,它会再次回显
1
。发生的情况是检查失败,并转到检查后的行-在本例中为gotoTWO(默认情况下)。你能确保你正在检查的内容和你正在输入的内容确实匹配吗?foxidrive和prabindh。。。很抱歉我修好了哈哈。是的,我在实际代码中输入了错误的代码。
goto :EOF
:gotoTWO
if %choice% equ 1 GOTO gotoONE
if %choice% equ 2 GOTO gotoTWO