这段代码应该是这样的,如果我按1 - 4它会去的选项1 - 4,如果我按其他东西它会说它不是一个选项。但如果我输入其他东西,它仍然会进行调试。这个IF NOT语句有什么问题?
而且我检查了几次代码,我找不到错误。我甚至将它与这样的代码进行了比较,这些代码实际上工作正常,我甚至按Ctrl-c Ctrl-v'ed它,它仍然无法工作。
:admin
cls
color %debug%
echo You have accessed the admin debug menu
echo Do what you wan't
echo [1] Set Debug color
echo [2] Set Default color
echo [3] Set Warning color
echo [4] Exit
set /p "lol=> "
IF /i %lol%==1 goto dbg if NOT goto 9
IF /i %lol%==2 goto dfc if NOT goto 9
IF /i %lol%==3 goto wnc if NOT goto 9
IF /i %lol%==4 goto start if NOT goto 9
:dbg
cls
color %debug%
echo Set Debug color
set /p "debug=> "
echo Debug color set to %debug%
color %debug%
pause
goto admin
:dfc
cls
color %debug%
echo Set Default color
set /p "default=> "
echo Default color set to %default%
pause
goto admin
:wnc
cls
color %debug%
echo Set Warning color
set /p "warning=> "
echo Warning color set to %warning%
pause
goto admin
:9
cls
color %warning%
echo This is not a viable option!
ping localhost -n 5 >nul
goto admin
我测试出来,当我键入EX 5它仍然去调试。
你的第一个'if'会,修正时,去'dbg'或'9'。它不会执行任何其他比较,因为执行将转移到'dbg'或'9'。 – Magoo
请通过在命令提示符窗口中输入“if /?”来阅读'if'命令的帮助;你会发现你需要在这里的'else'子句... – aschipfl