I try to use this code for choices of actions. Is there any simplified script refer to the choice of selection then goto that function block instead of hardcoding the IF %choice% from A to Z ?
set "choices= ABCDEFGHIJKLMNOPQRSTUVWXYZ"
choice /n /c %choices:~1% /m "Select Task Opton: "%1
set "choice=!choices:~%errorlevel%,1!"
if %choice%==A goto A
if %choice%==B goto B
if %choice%==C goto C
CodePudding user response:
Since I trust that you wouldn't be foolish enough to make it possible for the user to select a choice that didn't have a corresponding label, you can simply goto %choice%
as the last line instead of all of those if
statements.