gpt4 book ai didi

后藤此时出乎意料——批处理

转载 作者:行者123 更新时间:2023-12-04 22:33:39 26 4
gpt4 key购买 nike

我正在尝试制作一个基于文本的批处理游戏。但是我刚开始写我以前从未遇到过的问题时遇到了一个问题。

:menu
:: the game menu - opens when the game starts
cls
echo This game is still being made -- expermintal
echo Start Screen:
echo [1] View Changes
echo [2] Start Game
echo enter your choice:
set /p startchoice =
if %startchoice%==1 goto changes
if %startchoice%==2 goto startgame

当我输入 1 或 2 时,它显示错误“此时转到意外”我该如何解决?

最佳答案

您的 startchoice 设置不正确。使用 set /p 的替代语法,在那里提供提示(并删除 startchoice 和赋值( = )运算符之间的空格 - 我认为这实际上是问题的原因,但是如果您使用,您可以将批处理文件减少一行set /p <variable>=<Prompt> 语法)。

我为 gotoecho 语句添加了两个目标,以便您可以看到它们已达到:

:menu
:: the game menu - opens when the game starts
cls
echo This game is still being made -- expermintal
echo Start Screen:
echo [1] View Changes
echo [2] Start Game
set /p startchoice=Enter your choice:

if %startchoice%==1 goto changes
if %startchoice%==2 goto startgame
:changes
echo Changes
goto end
:startgame
echo StartGame
:end

关于后藤此时出乎意料——批处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14077840/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com