Wednesday, November 16, 2011

A simple menu that rejects invalid options

@ECHO off
cls
:start
ECHO DEFAULTS TO D WHICH WILL FAIL.
ECHO A. Case insensitive
ECHO b. second option
set choice=D
set /p choice=Type the letter
if not '%choice%'=='' set choice=%choice:~0,1%
REM the next line is case insensitive
if /I '%choice%'=='A' goto optiona
if '%choice%'=='b' goto optionb
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:optiona
ECHO You typed A
goto end
:optionb
ECHO You typed B
goto end
:end
GOTO START