RosettaCodeData/Task/Menu/Batch-File/menu.bat

27 lines
501 B
Batchfile
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
@echo off
2019-09-12 10:33:56 -07:00
call:menu "fee fie" "huff and puff" "mirror mirror" "tick tock"
2015-11-18 06:14:39 +00:00
pause>nul
2019-09-12 10:33:56 -07:00
exit /b
2015-11-18 06:14:39 +00:00
2019-09-12 10:33:56 -07:00
:menu
cls
setlocal enabledelayedexpansion
set count=0
set reset=endlocal ^& goto menu
:menuloop
for %%i in (%*) do (
set /a count+=1
set string[!count!]=%%~i
echo string[!count!] = %%~i
2015-11-18 06:14:39 +00:00
)
echo.
2019-09-12 10:33:56 -07:00
set /p choice=^>
if "%choice%"=="" %reset%
set "isNum="
for /f "delims=0123456789" %%i in ("%choice%") do set isNum=%%i
if defined isNum %reset%
if %choice% gtr %count% %reset%
echo.!string[%choice%]!
goto:eof