(view source code of pmchoice.kix as plain text)
; PMCHOICE.KIX, Version 2.00 for Windows NT; Poor Man's replacement for the CHOICE command from the NT Resource Kit.; Needs PMCHOICE.BAT to convert original parameters to Kix variables.; Requires KiXtart 4.01 or later if a timeout is specified.; Batch/KiXtart combination follows the original CHOICE.EXE syntax.; Written by Rob van der Woude; http://www.robvanderwoude.com; Show text if requiredIf $Text <> ""
$Text
EndIf
; Show prompt if requiredIf $NoPrompt <> 1
"? [" + $Choices + "]"
EndIf
:StartIf $TimeOut = 0
; Wait infinitely for key to be pressedGet $Key
Else
; Requires at least KiXtart 4.01$KixMajorVer = SubStr( @Kix, 1, InStr( @Kix, "." ) - 1 )
If $KixMajorVer < 4
Cls
? "PMChoice.kix requires KiXtart version 4.01 or later."
? "Your KiXtart version is " + @KIX + "."
?Quit 255
EndIf
; Check if key is pressedIf KbHit( )
Get $Key
Else
; Check if key is pressed each second during timeout interval$Counter = 0
; Default in case no key will be pressed before end of timeout$Key = Chr( 13 )
Do
Sleep 1
$Counter = $Counter + 1
If KbHit( )
; Once pressed, read and then exit loopGet $Key
$Counter = $TimeOutEndIf
Until $Counter = $TimeOut
EndIf
EndIf
; Pressing Esc results in return code 0If $Key = Chr( 27 )
Exit 0
EndIf
; Pressing Enter results in default (if defined!)If $Key = Chr( 13 )
$Key = $DefaultEndIf
; The return code must be the position of the key in the choices string$Return = InStr( "$Choices", "$Key" )
; Beep and start again if an invalid key was pressedIf $Return = 0
Beep
GoTo Start
EndIf
; If cases sensitivity was defined, check if the cases matchIf $Cs = "1"
If Asc( SubStr( "$Choices", $Return, 1 ) ) <> Asc( $Key )
Beep
GoTo Start
EndIf
EndIf
; Exit with the proper return codeExit $Return
page last modified: 2025-10-11; loaded in 0.0074 seconds