How to create a option menu
Posted: 20 Oct 2013 04:36
Hello guys again, Here I will show you how you may create an Options Menu, this is very simple.
Here is a code example I will use, than I shall explain what each command does;
Ok so I will explain...
You need to create a variable using "SET". Than the "/P" is saying to the file, Pause and wait for a response from the user.
The "Echo" 's allow you to see the options.
The "%OPT%" variable is what you created in the beginning, allowing you to use that as code.
The "==" basically means, if you type that digit "1/2/3" into the line that says:
... Than that is the answer you decide and want to select.
The "GOTO" command, sends you to whatever point you want, i.e ":Exit".
That's how you can make an Option Menu. You can change the code to your liking, and use it for your own batch files.
Have fun and enjoy...
.Batch Artist.
Here is a code example I will use, than I shall explain what each command does;
Code: Select all
@ECHO off
SET /P OPT=Which option would you like?
ECHO 1) Calculator
ECHO 2) Timer
ECHO 3) Exit
IF %OPT%==1 GOTO :Calculator
IF %OPT%==2 GOTO :Timer
IF %OPT%==3 GOTO :Exit
:Calculator
REM "Code for Calculator"
:Timer
ECHO %time%
:Exit
Exit
Ok so I will explain...
You need to create a variable using "SET". Than the "/P" is saying to the file, Pause and wait for a response from the user.
The "Echo" 's allow you to see the options.
The "%OPT%" variable is what you created in the beginning, allowing you to use that as code.
The "==" basically means, if you type that digit "1/2/3" into the line that says:
Code: Select all
SET /P OPT=Which option would you like?
... Than that is the answer you decide and want to select.
The "GOTO" command, sends you to whatever point you want, i.e ":Exit".
That's how you can make an Option Menu. You can change the code to your liking, and use it for your own batch files.
Have fun and enjoy...
.Batch Artist.