跳至批处理程序的下一步

时间:2018-11-06 21:23:41

标签: batch-file

    @echo off
    setlocal EnableDelayedExpansion
    color b
    goto play

    :play
    cls
    set name2= OoggieBoogie
    echo Hello, My name is !name2!^^! I'm an AI. I'm here to help with your lazy 
    Butt :D^^!
     timeout /t 3 >null

echo!name2!: May I Have Your Have Your Name Please? :)
color c
echo (Pssst^^! Want to cut the Bullshit and go straight in? Select "Express" please!)
timeout /t 2 >null
echo A. My name is 
echo B. Express
set /p input=
if !input! equ B goto Writing2


cls
echo!name2!: Hello !name!, Shall we continue now?
echo 1.Yes :D
echo 2.No  -_-" ..
set /p input=!name!:
if !input! equ 1 goto Writing
if !input! equ Yes goto Writing
if !input! equ 2 exit
if !input! equ No exit



:Writing2
echo Okay.. Whatever you want Damn.. I was trying to be nice ^^!
echo Anyway. Inatiating EXPRESS Route----->
goto Writing

你好! 我要在这里执行的操作是跳过所有步骤,如果键入Express,则直接转到“ Writting2”。

这个有趣的程序几乎完成了,但是我想不出一种跳过所有步骤的好方法。 当我输入“ Express”或选择“ B”时 它崩溃了。 但是如果我写一个名字,程序将照常工作!

预先感谢! 抱歉,如果我在社区中做错了事。

1 个答案:

答案 0 :(得分:0)

这是您可以做自己想做的一种方式:

@echo off
color b
goto play

:play
cls
set name2= OoggieBoogie
echo Hello, My name is %name2% I'm an AI. I'm here to help with your lazy 
::echo Butt :D^^!
timeout /t 3 >nul

echo %name2%: May I Have Your Have Your Name Please? :)
color c
echo (Pssst^^! Want to cut the Bullshit and go straight in? Select "Express" please!)
timeout /t 2 >nul
echo A. My name is 
echo B. Express
choice /c:AB>NUL
if errorlevel 2  goto Writing2
set /p "name=Enter your name: "

:Writing
cls
echo %name2%: Hello %name%, Shall we continue now?
echo 1.Yes :D
echo 2.No  -_-" ..
choice /c:1Y2N>NUL
if errorlevel 4  goto exit
if errorlevel 3  goto exit
if errorlevel 2  goto Writing
if errorlevel 1  goto Writing


:Writing2
echo Okay.. Whatever you want Damn.. I was trying to be nice ^^!
echo Anyway. Inatiating EXPRESS Route-----^>
goto Writing

:exit
exit /b

请记住:%variable_name%可以访问变量,而set "variable_name=variable_value"可以将它们设置为上述@Compo。 最好在以后的批处理文件中使用choice /c选项。此选项的缺点是您不能输入超过1个字符的字符串,但这是它自己的错误处理,因此您不必处理无效的响应。另外,当你写

echo Anyway. Initiating EXPRESS Route----->

>符号会引起问题,因为它是重定向字符,应转义:

echo Anyway. Initiating EXPRESS Route-----^>