gpt4 book ai didi

batch-file - 批处理脚本 : Using GOTO on IF statement

转载 作者:行者123 更新时间:2023-12-02 17:18:36 24 4
gpt4 key购买 nike

当你到达用户输入部分时,无论我输入什么( table 、火、门),它总是转到壁炉。我的 if 语法有问题吗?

    @echo off
color C
title RG Text Game
echo -------------------------------------------------
echo Welcome to the Game!
echo.
echo -------------------------------------------------
echo.
pause

echo.
echo Blah bah blah story story
echo What do you want to do?
echo Choices: fire/desk/door
set /p choice=
if %choice%=="fire" GOTO fireplace
if %choice%=="desk" GOTO desk
if %choice%=="door" GOTO door

:fireplace
echo.
echo You come to the fireplace.
echo.
pause

:desk
echo.
echo You go to the desk.
echo.

:door
echo.
echo You go to the door.
echo.

最佳答案

双引号 %choice% 否则将不相等:desk 不等于 "desk"

然后使用 goto:eofexit/b 退出您的 Label block 。

/i 开关与 IF 一起使用,这样您也可以使用 DESKDesK

 if /i "%choice%"=="fire" GOTO fireplace
if /i "%choice%"=="desk" GOTO desk
if /i "%choice%"=="door" GOTO door
goto:error

:fireplace
echo.
echo You come to the fireplace.
echo.
pause
exit/b

:desk
echo.
echo You go to the desk.
echo.
exit/b

:door
echo.
echo You go to the door.
echo.
exit/b

关于batch-file - 批处理脚本 : Using GOTO on IF statement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44722903/

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