我遇到批处理文件崩溃的问题

时间:2016-08-01 21:28:18

标签: batch-file

我无法解决此问题,我希望能够将任何内容编写为适用的响应     :存在 但不是     :FAP的

这是我的代码

:begin 
cls
echo You wake up and realize you are never going to amount to anything, oh      well, might as well get on with your worthless life
echo fap or vidya games
echo.
set /p input=
if /i "%input%"=="Fap" goto Fap
if /i "%input%"=="Vidya games" goto vidya games
if /i "%input%"=="vidya" goto vidya games 
if not "%input%"=="Fap"/"vidya"/"Vidya games" goto begin

:Fap
cls
echo Since you can't get a girl you decide to fantize about the girl of your   dreams so you download some watamote doujins after a mixture of crying and masterbaiting you decide to change to mood
echo vidya or sleep
echo.
set /p input=
if /i "%input%"=="vidya" goto vidya fap
if /i "%input%"=="sleep" goto sleep
if not "%input%"=="vidya"/"sleep" goto Fap

2 个答案:

答案 0 :(得分:0)

批处理脚本中的标签由:begin之类的冒号标记。从IF,FOR或类似语句重定向到某个标签时使用相同的方法。因此,请按照以下示例编辑脚本:

if /i "%input%"=="Fap" (goto :Fap
) else if /i "%input%"=="Vidya" (goto :Vidya_games
) else (goto :begin)

答案 1 :(得分:0)

您可以检查标签是否存在,如果是,则跳转到它,而不是那些if

如果您有多个不同目的地的问题,可以相应地命名标签:

@echo off
:loop 
echo fap or vidya games
set /p "label=Command: "
findstr /b /i ":Q1-%label%" "%~f0" && goto :Q1-%label% 
REM previous line checks, if the label exists and if yes, jumps to it
echo no such command: %label% & goto :loop

:Q1-fap
echo reached Question1 label one.
goto :eof

:Q1-vidya
echo reached Question1 label two.
goto :eof

一些注意事项:
标签只是单个字。忽略第一个空格后的所有内容 findstr /i使其对大小写不敏感 /b会搜索以字符串开头的行 &&表示“如果上一个命令(此处为findstr)成功,则表示” %~f0是批处理文件的名称。

当您输入Q1-vidyavidyaVidyaVIDYavidya Games时,这会转到Vidya anything

相关问题