(Posting this because I couldn't get a straight answer from google, so I've written up how I did it incase anyone else runs into the same problem)
While using my palmtop (HP200LX!!), which runs MS-DOS 5.0, i decided i needed a batch file to ask a yes/no question and get an answer. Unfortunately, under MS-DOS 5.0, there is no way to accommodate this. There wasn't even the program 'Choice' on it. While flicking through my manual, I saw something that said
"A very common form of use of Errorlevel depends on a short program not usually found on MS-DOS disks called YN. This returns an errorlevel of 1 if the n key is pressed when the program runs."
I didn't have this program, so i decided to make one myself using something I'd never used before: Debug.
After a bit of googling, and looking on
i had my source code ready!
0100 mov ah, 01 ; keyboard input subprogram. all the examples have an h after 01, is used, but in debug remove it or else face an error.
0102 int 21h ; read character into al. Removal of h not necessary here
0104 cmp al, 79 ; compare al with the hex value of lowercase y, 79
0106 jne 010D ; jump if they're different to line 010D
0108 mov ax, 4c00 ; return to ms-dos. Errorlevel 0
010B int 21h
010D mov ax, 4c01 ; return to ms-dos. Errorlevel 1
0110 int 21h
The next step was to enter it into debug. Using instructions from
I entered the code, using these keystrokes.
C:\>DEBUG
-N YN.COM
-A
0100 mov ah, 01
0102 int 21h
0104 cmp al, 79
0106 jne 010D
0108 mov ax, 4c00
010B int 21h
010D mov ax, 4c01
0110 int 21h
0112
-RCX
CX0000
:10
-W
00010 Bytes Written
-Q
C:\>
Now, my program was ready!
Note: RCX and its 10 input was used to set the number of bytes that needed to be written. (Hexadecimal 0110 - 0100 = 10) The write command will not function without RCX being used first.
Heres the example i used:
@echo off
echo Press y or n...
yn
echo.
if errorlevel == 1 goto n
if errorlevel == 0 goto y
:y
echo You pressed Y!
goto end
:n
echo You pressed N...
:end
Anyways, if you ever need a YN substitute i hope this helps! Cheers XD