batch file - How to use multiple answers for the same IF statement -
i have created simple riddles program on cmd using batch file. answers such 1 can answered 1 aswell. far have this:
:riddle_1 cls echo. echo shake earth booming thunder echo fell forests whole , homes complete. echo influence ships, topple kings echo sweep down swift yet remain unseen. echo. set /p answer=what i? if %answer%==wind (goto riddle_2) else (goto riddle_1)
when try:
if %answer%==wind (goto riddle_2) else (goto riddle_1) if %answer%==wind (goto riddle_2) else (goto riddle_1)
it ignores second command altogether other variations or ignore else command , make go next question when answer wrong.
is there anyway fix this??
the /i
makes compare case insensitive , double quotes make more robust in various ways.
if /i "%answer%"=="wind" (goto riddle_2) else (goto riddle_1)
Comments
Post a Comment