So i was writing a batch file for fun and i had a multiple choice statement, so i had it like this:
@echo off
title John's apples
echo.
echo John got 3 apples, he gives 1 away. How many does he have then?
echo (Please answer with ONE capital letter, or type Exit to exit.)
echo =============
echo.
echo A) 2.5
echo B) 3.459475945
echo C) 2
echo D) 1
echo Exit
echo.
:answer
set /p ans=Your Answer:
if "%
if "%ans%"=="a" Echo Please answer with a capital letter!&set /p ans=Your Answer:
if "%ans%"=="b" Echo Please answer with a capital letter!&set /p ans=Your Answer:
if "%ans%"=="c" Echo Please answer with a capital letter!&set /p ans=Your Answer:
if "%ans%"=="d" Echo Please answer with a capital letter!&set /p ans=Your Answer:
if "%ans%"=="A" Echo Wrong! The answer was 2.
if "%ans%"=="B" Echo Wrong! The answer was 2.
if "%ans%"=="C" Echo Right! Good job! The answer was 2.
if "%ans%"=="D" Echo Wrong! The answer was 2.
if "%ans%"=="Exit" exit
Pause
Exit
So now i wanna know, if someone puts the wrong answer in (because you have to put a capital letter in, otherwise it will not work) it says nothing. So i wanna know how i do something like: If A,B,C,D are not the input, print "Please enter a valid answer!"
Can anybody help? this might be asked already, sorry for that...there might be some random thingy's in the script because i was testing some around.
Aucun commentaire:
Enregistrer un commentaire