(view source code of pmchoice.bat as plain text)
@ECHO OFF
:: Keep variables local:
SETLOCAL
:: Check if help was asked:
IF [%1]==[/?] GOTO Syntax
:: Set default values:
SET Choices=YN
SET Cs=0
SET Default=
SET Error=0
SET NoPrompt=0
SET Text=
SET TimeOut=0
SET Type=
:: Parse command line:
FOR %%A IN (%*) DO CALL :Parse %%A
:: Remove leading space from text prompt:
IF "%Text%"==" " SET Text=
IF "%Text%"=="" GOTO ErrCheck
IF "%Text:~0,1%"==" " SET Text=%Text:~1%
:: Stop if an error occured:
:ErrCheck
IF NOT [%Error%]==[0] GOTO Syntax
:: Call the Kix helper script:
KIX32.EXE "%~dpn0.kix" $Choices=%CHOICES% $Cs=%Cs% $Default=%Default% $NoPrompt=%NoPrompt% $Text="%Text%" $TimeOut=%TimeOut%
:: Show help if KiXtart version is too old:
IF %ERRORLEVEL% GEQ 250 GOTO Syntax
:: Return the appropriate errorlevel:
EXIT %ERRORLEVEL%
GOTO End
:Syntax
ECHO.
ECHO PMCHOICE.BAT, Version 2.00 for Windows NT / 2000 / XP
ECHO Poor Man's replacement for the CHOICE command
ECHO Helper batch file for PMCHOICE.KIX, Version 2.00
ECHO.
ECHO Usage: [CALL] PMCHOICE [/C[:]choices] [/N] [/S] [/T[:]c,nn] [text]
ECHO.
ECHO Where: /C[:]choices Specifies allowable keys. Default is YN.
ECHO /N Do not display choices and ? at end of prompt string.
ECHO /S Treat choice keys as case sensitive.
ECHO /T[:]c,nn Default choice to c after nn seconds or on pressing Enter.
ECHO text Prompt string to display.
ECHO.
ECHO Result: ERRORLEVEL is set to offset of key user presses in choices.
ECHO.
ECHO Note: Requires KiXtart 4.01 or later.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:End
ENDLOCAL
GOTO:EOF
:Parse
:: Parse the command line one word at a time:
SET Param=%1
IF /I [%Type%]==[/T] (
SET TimeOut=%Param%
SET Type=
GOTO:EOF
)
SET Type=%Param:~0,2%
IF /I NOT [%Type%]==[/C] IF /I NOT [%Type%]==[/N] IF /I NOT [%Type%]==[/S] IF /I NOT [%Type%]==[/T] (
SET Text=%Text% %Param%
GOTO:EOF
)
IF /I [%Type%]==[/S] (
SET Cs=1
GOTO:EOF
)
IF /I [%Type%]==[/N] (
SET NoPrompt=1
GOTO:EOF
)
SET Param=%Param:~2%
IF [%Param:~0,1%]==[:] SET Param=%Param:~1%
IF /I [%Type%]==[/C] (
SET Choices=%Param%
GOTO:EOF
)
IF /I [%Type%]==[/T] SET Default=%Param%
IF /I [%Type%]==[/T] (
ECHO.%Choices% | FIND /I "%Default%" >NUL
IF ERRORLEVEL 1 SET Error=1
)
GOTO:EOF
page last modified: 2024-04-16; loaded in 0.0098 seconds