The Debug program at the end of this article will wait for you to
input a character from the keyboard and set the value of "errorlevel"
equal to the ASCII code value of the character entered. For a list of
ASCII characters and their associated values, see the ANSI.SYS section
in your MS-DOS manual.
Most keyboard characters are represented by only one code. However, the
functions and ALT key combinations send two codes: a zero, followed by
another code. The REPLY.COM program will set "errorlevel" equal to the
second code passed. For example, the F8 key sends a zero followed by
the value 66. This will be interpreted by REPLY.COM as the character
"B," which has an ASCII value of 66.
REPLY.COM can be used within batch files to allow user input to control
the flow of the program. For example, the following AUTOEXEC.BAT file
allows you to determine whether or not to install a mouse driver
Echo Install Mouse Driver (y/n)?
If errorlevel 121 if not errorlevel 122 goto install
If errorlevel 89 if not errorlevel 90 goto install
If errorlevel 110 if not errorlevel 111 goto NoMouse
If errorlevel 78 if not errorlevel 79 goto NoMouse
For more information about using the "errorlevel" environment
variable, query on the following word in the Microsoft Knowledge Base:
To create REPLY.COM, enter the text listed in the Instruction column.
Press ENTER after each instruction. Do not enter the text listed in
the Comment column; it is for your reference.
DEBUG Executes MS-DOS DEBUG utility
-A 100 Begin assembling instructions at memory location
xxxx:0100 MOV AH,08 Get character input without echo
xxxx:0102 INT 21 Perform MS-DOS service
xxxx:0104 CMP AL,0 Compare AL with zero
xxxx:0106 JNZ 010A If lead zero, get second code of character
xxxx:0108 INT 21 Perform MS-DOS service
xxxx:010A MOV AH,4C Terminate process with return code
xxxx:010C INT 21 Perform MS-DOS service
Writing 000E bytes