Batch Beta
Please Login to get full access and to disable ads.

Join the forum, it's quick and easy

Batch Beta
Please Login to get full access and to disable ads.
Batch Beta
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Thanks to awestom for removing those ads!

Staff Selections are closed! Thanks for participating!
Welcome to the new admins and mods!
About the ads, yeah. We reached our 250'th post and the ads kicked on. In order to disable them I need to purchase a ad removal feature. Now, I don't have credits and in order to get one I need donations. Thanks

You are not connected. Please login or register

How to properly make a menu

2 posters

Go down  Message [Page 1 of 1]

1How to properly make a menu Empty How to properly make a menu Thu Jan 13, 2011 4:30 pm

Forum_Reader

Forum_Reader
Jr Admin
Jr Admin

Now, I've seen a lot of people improperly make menus, so I've decided to make a quick tutorial on how to make a proper menu.

Making a menu is quite straight-forward. First, make a label. Let's call it, menu1.
Code:
:menu1
Now, you need to display the options. Let's make 3.
Code:
echo 1. Option 1
echo 2. Option 2
echo 3. Exit
Then you need to get user input.
Code:
set /p choice=Option ^(1/2/3^)
This is the part that most people mess up on: properly executing commands depending on the user's choice. If you are using alphabetical options instead of numerical, use the code from the next code box.
Code:
REM - NUMERICAL OPTIONS -
if %choice%==1 goto option1
if %choice%==2 goto option2
if %choice%==3 exit
Code:
REM - ALPHABETICAL OPTIONS -
if /i "%choice%"=="a" goto optionA
if /i "%choice%"=="b" goto optionB
if /i "%choice%"=="c" exit
You may notice that I didn't add options for capital letters. That's what the /i switch is for. It means case-insensitive. That means it will compare the two items, but disregard case.
Next is an important part of the menu. If the dumb user gives an incorrect option, what do you do? Add this code and the issue will be solved.
Code:
cls
echo '%choice%' is an invalid option. Please try again.
REM The next line will change depending on what the original label is.
goto menu1

Now, the final code would be:
Code:
REM - NUMERICAL MENU
:menu
echo 1. Option 1
echo 2. Option 2
echo 3. Exit
set /p choice=Option ^(1/2/3^)
if %choice%==1 goto option1
if %choice%==2 goto option2
if %choice%==3 exit
cls
echo '%choice%' is an invalid option. Please try again.
goto menu
Code:
REM - ALPHABETICAL MENU
:menu
echo A. Option 1
echo B. Option 2
echo C. Exit
set /p choice=Option ^(A/B/C^)
if /i "%choice%"=="a" goto optionA
if /i "%choice%"=="b" goto optionB
if /i "%choice%"=="c" exit
cls
echo '%choice%' is an invalid option. Please try again.
goto menu


So, there it is. If you guys have any questions, comments, or concerns, speak freely.

2How to properly make a menu Empty Re: How to properly make a menu Thu Jan 13, 2011 4:46 pm

-xPloit

-xPloit
Moderators
Moderators

I think a good point to emphasize here is that the "graphical menu" is not literally a menu. If you have too many items on your menu, it becomes bothersome to scroll up and down trying to find what you want. You can, to make things easier, double them up. Make the menu 2x wider and therefore, 2x shorter. But the code for managing the selection would still be the same

For example:
Code:

echo 1) This is option 1
echo 2) This is option 2
echo 3) This is option 3
echo 4) This is option 4

can be written as:
Code:

echo 1) This is option 1          3) This is option 3
echo 2) This is option 2          4) This is option 4

and the set /p choice code would still work exactly the same. It's something I've noticed with people and their menus...they put a menu of 20+ items and it's in a 1x20 grid, rather than 5x4 or something scratch

Good tut FR ^^ just had to add my 2 cents worth haha

3How to properly make a menu Empty Re: How to properly make a menu Thu Jan 13, 2011 5:07 pm

Forum_Reader

Forum_Reader
Jr Admin
Jr Admin

-xPloit wrote:I think a good point to emphasize here is that the "graphical menu" is not literally a menu. If you have too many items on your menu, it becomes bothersome to scroll up and down trying to find what you want. You can, to make things easier, double them up. Make the menu 2x wider and therefore, 2x shorter. But the code for managing the selection would still be the same

For example:
Code:

echo 1) This is option 1
echo 2) This is option 2
echo 3) This is option 3
echo 4) This is option 4

can be written as:
Code:

echo 1) This is option 1          3) This is option 3
echo 2) This is option 2          4) This is option 4

and the set /p choice code would still work exactly the same. It's something I've noticed with people and their menus...they put a menu of 20+ items and it's in a 1x20 grid, rather than 5x4 or something scratch

Good tut FR ^^ just had to add my 2 cents worth haha
Very smart!

4How to properly make a menu Empty Re: How to properly make a menu Fri Jan 14, 2011 11:27 am

-xPloit

-xPloit
Moderators
Moderators

i know, I'm a genius ^^

Sponsored content



Back to top  Message [Page 1 of 1]

Similar topics

-

» Lets Make Bank for our Bb

Permissions in this forum:
You cannot reply to topics in this forum