Okay, I have a file needs user input (1 through 5) how do I restrict the user input. Say if someone typed "r" or another character other than 1 through 5 how would I block that input because when I input an unexpected character is crashes the program instead of ingoing it.
Okay, I have a file needs user input (1 through 5) how do I restrict the user input. Say if someone typed "r" or another character other than 1 through 5 how would I block that input because when I input an unexpected character is crashes the program instead of ingoing it.
I'm not exactly a DOS or batch guru, but I have used simple batch files extensively in the past
Can't you make a statement along the lines of
1@ECHO OFF 2 3:Top 4CLS 5@ECHO Your Main Menu 6@ECHO -------------- 7@ECHO Option [1] 8@ECHO Option [2] 9@ECHO Option [3] 10@ECHO Option [4] 11@ECHO Option [5] 12@ECHO. 13@ECHO [Q]uit 14@ECHO. 15CHOICE /C:12345Q 16IF ERRORLEVEL 6 GOTO Quit 17IF ERRORLEVEL 5 GOTO Option5 18IF ERRORLEVEL 4 GOTO Option4 19IF ERRORLEVEL 3 GOTO Option3 20IF ERRORLEVEL 2 GOTO Option2 21IF ERRORLEVEL 1 GOTO Option1 22 23:Option1 24CLS 25@ECHO This is Option 1! 26@ECHO Press any key to return to the main menu... 27PAUSE>NUL 28GOTO Top 29 30:Option2 31CLS 32@ECHO This is Option 2! 33@ECHO Press any key to return to the main menu... 34PAUSE>NUL 35GOTO Top 36 37:Option3 38CLS 39@ECHO This is Option 3! 40@ECHO Press any key to return to the main menu... 41PAUSE>NUL 42GOTO Top 43 44:Option4 45CLS 46@ECHO This is Option 4! 47@ECHO Press any key to return to the main menu... 48PAUSE>NUL 49GOTO Top 50 51:Option5 52CLS 53@ECHO This is Option 5! 54@ECHO Press any key to return to the main menu... 55PAUSE>NUL 56GOTO Top 57 58:Quit 59CLS 60@ECHO Hasta la vista, Baby!