| DosTips.com ... for VISTA,XP,NT,Server 2000,Server 2003,Server 2008 |
|
Last update: Dec 6, 2008 |
This simple menu framework parses itself for batch labels of certain signature and lists them as menu items. The self-parsing feature makes the menu generic. New menu items can be inserted by adding new function blocks without changing the menu infrastructure.
Features:
| |
|
- @ECHO OFF
- REM.-- Prepare the Command Processor
- SETLOCAL ENABLEEXTENSIONS
- SETLOCAL ENABLEDELAYEDEXPANSION
- :menuLOOP
- echo.
- echo.= Menu =================================================
- echo.
- for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~f0""') do echo. %%B %%C
- set choice=
- echo.&set /p choice=Make a choice or hit ENTER to quit: ||GOTO:EOF
- echo.&call:menu_%choice%
- GOTO:menuLOOP
- ::-----------------------------------------------------------
- :: menu functions follow below here
- ::-----------------------------------------------------------
- :menu_1 Have some fun
- echo.Have some fun by adding some more code right here
- GOTO:EOF
- :menu_2 Get a water
- echo.Get a water and then add some code right here
- GOTO:EOF
- :menu_
- :menu_T Tip
- echo.It's easy to add a line separator using one or more fake labels
- GOTO:EOF
- :menu_C Clear Screen
- cls
- GOTO:EOF