简体   繁体   English

DOS批处理文件:否则对goto语句了解?

[英]DOS Batch File: If else goto statement understanding?

Making a batch program and I seem to have run into a problem with if and else statements. 制作一个批处理程序,我似乎遇到了if和else语句的问题。

I am trying to make it goto another line if anything else then "list" is typed. 我试图使它转到另一行,如果键入“列表”之后还有其他内容。

Can anybody tell me what I did wrong? 谁能告诉我我做错了什么?

Code: 码:

@echo off
:start
echo PROVOLONE-------------------------
echo ------------------------------TEAM
echo -------------PRESENTS-------------
echo The Simple Batch Program Collection
echo 2015 Provolone Team
sleep 3
echo. 
echo First, let's start off by listing what programs we have.
sleep 2
goto tutorial
:tutorial
echo type in "list"
set /p list="provolone>"
if %list%== "list" goto list else goto wronglist
:wronglist
echo I said type in "list!" not %list% !
sleep 2
goto tutorial
:list
echo.
echo All SBPC Programs as listed
echo starting with program names
echo placeholder
pause

比较中包括了引号,因此在比较的两边都需要使用引号:

if "%list%"== "list" goto list else goto wronglist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM