I would like to add special characters like < | into my choice command, how can I do that?
Here's my old code:
CHOICE /C ABCDEFGHIJKLMNOPQRSTUVWXYZ0134567928 /N /M "Press 8 ...."
and I would like it to be something like :
CHOICE /C `~,.<>?ABCDEFGHIJKLMNOPQRSTUVWXYZ0134567928 /N /M "Press 8 ...."
Any help will be appreciated, thanks.
EDIT: Since some of you may ask why do I need so many choice, I'm here to answer. It is because pressing an invalid choice would give you an annoying beep that I would not like. Therefore I asked this question.
The CHOICE command only allows alpha-numeric characters, as well as extended ASCII characters with decimal byte codes between 128-254.
I have written a pure batch substitute for CHOICE based on a hack that uses REPLACE. My
:getKeyroutine can accept most any character, and allows you to specify the allowed characters, and it puts the captured character in a variable of your choosing - much more convenient than messing with ERRORLEVEL.I originally posted the routine at http://www.dostips.com/forum/viewtopic.php?f=3&t=7396. The link also has a more complicated routine that can read absolutely any key value, including NULL, as well as a routine that allows input of a masked string (displays asterisks for each character).
Below is the :getKey routine, along with an example showing usage. Remove the
/Iswitch if you want the keys to be case sensitive. Full documentation is embedded within the script.Edit - I've updated the code to version 2.0 with the ability to specify a prompt, and to have the valid key list be case sensitive. The only CHOICE feature that cannot be emulated is a timeout option with a default response. I don't see any reasonable way to ever provide a timeout option.