Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Choice options goto respective functions

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading