【发布时间】:2014-08-18 13:26:24
【问题描述】:
我使用批处理文件在 CMD 上创建了一个简单的谜语程序。我希望它也可以回答诸如 1 之类的答案。到目前为止,我有这个:
:Riddle_1
cls
echo.
echo I shake the earth with booming thunder
echo fell forests whole and homes complete.
echo I influence ships, topple kings
echo sweep down swift yet remain unseen.
echo.
set /p answer=What am I?
if %answer%==wind (goto Riddle_2) else (goto Riddle_1)
当我尝试时:
if %answer%==wind (goto Riddle_2) else (goto Riddle_1)
if %answer%==Wind (goto Riddle_2) else (goto Riddle_1)
它完全忽略第二个命令,其他变体会这样做,否则它们将忽略 else 命令并在答案错误时将其转到下一个问题。
有没有办法解决这个问题?
【问题讨论】:
-
这只需要一个忽略大小写的 IF,foxidrive 演示了如何。如果您确实想匹配多个值,例如“风”或“阵风”,请参阅IF… OR IF… in a windows batch file
标签: batch-file cmd