China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-02 08:23
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » Help, how to implement waiting for user input in a batch script? View 1,489 Replies 4
Original Poster Posted 2007-12-06 01:02 ·  中国 四川 成都 电信
初级用户
Credits 27
Posts 12
Joined 2006-09-15 01:41
19-year member
UID 62605
Status Offline
During the execution of the batch processing, wait for user input. Originally, I wanted to use set/p xxx=yyy to achieve it, but found that it didn't work. There is no /P parameter in pure DOS. Is there any other way? It can't be CHOICE because the number of characters to be input is more than 2.
Floor 2 Posted 2007-12-06 10:19 ·  中国 河北 保定 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
Under pure DOS, set /p is indeed not supported, so we have to use third-party programs. For example, wbat.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 3 Posted 2008-04-04 10:34 ·  中国 河南 郑州 联通
初级用户
Credits 35
Posts 17
Joined 2008-04-03 01:33
18-year member
UID 114814
Gender Male
Status Offline
For reference:
--------------------------
REPLY.COM is a batch file program used to allow user input to control the program flow. For example, the following AUTOEXEC.BAT file allows you to determine whether to install the mouse driver during startup:

@Echo off
path=C:\DOS
:Ask
Echo Install Mouse Driver (y/n)?
Reply
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
goto ask
:install
c:\mouse\mouse
:NoMouse
cls
ver


----------------------
REPLY.COM
To create REPLY.COM, enter the instructions listed in the instruction column. Press Enter after each instruction. Please do not enter the instructions listed in the comment column; it is for your reference.

Instruction Comment
----------- -------

DEBUG Executes MS-DOS DEBUG utility
-A 100 Begin assembling instructions at memory location
100
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
xxxx:010E <ENTER>
-rcx
CX 0000
:e
-n REPLY.COM
-w
Writing 000E bytes
-q
Floor 4 Posted 2008-04-06 16:06 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,284
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
Please explain the meaning of the return value on the 3rd floor to let everyone learn.
Floor 5 Posted 2008-04-07 01:26 ·  中国 北京 华为云
银牌会员
★★★
Credits 1,436
Posts 739
Joined 2007-10-11 17:44
18-year member
UID 99469
Gender Male
Status Offline
The assembly code on the 3rd floor can only input one character.

Read a character through the 8th function of the 21st interrupt, and store it in the al register. This result is the value in errorlevel.

And those 121, 89, 110, 78 respectively correspond to the decimal values of the ASCII codes of uppercase and lowercase letters y and n.
Forum Jump: