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-08-13 03:55
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Master Rushi, please come in: About your post "Batch Programming Tutorial" View 1,424 Replies 4
Original Poster Posted 2003-05-11 00:00 ·  中国 上海 徐汇区 电信
初级用户
★★
DOS爱好者
Credits 478
Posts 100
Joined 2003-04-22 00:00
23-year member
UID 1648
Gender Male
Status Offline
There is a passage like this in the post
====================================================
choice Using this command lets the user input a character, and then run different commands. When using it you should add the /c: parameter; after c: you should write the characters that may be entered in the prompt, with no spaces in between. Its return codes are 1234...

For example: choice /c:dme defrag,mem,end
will display
defrag,mem,end?

For example, the contents of test.bat are as follows:
@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto defrag should first test the highest error code
if errorlevel 2 goto mem
if errotlevel 1 goto end
===============================================


If the return code order after /c: is 1234......
Then shouldn't it be like this below:
if errorlevel 3 goto end should first test the highest error code
if errorlevel 2 goto mem
if errotlevel 1 goto defrag

|||||||  寻人启示:姓名:
| c●● ~年龄:20,性别:男
|  ♂▃~ 特征:帅.很帅.酷.特别酷....
| |︺英俊潇洒.风流倜傥,玉树临风→我

单钓E时代论坛
Floor 2 Posted 2003-05-12 00:00 ·  中国 湖北 武汉 汉阳区 电信
元老会员
★★★★★
步行的人
Credits 9,654
Posts 3,351
Joined 2003-03-11 00:00
23-year member
UID 1113
Gender Male
From 湖北
Status Offline
The /c parameter of choice allows the user to set the options, and the DOS system returns them one by one according to the order of the given options. The IF condition commands must be written in descending order of the return values, because this command makes the ERRORLEVEL condition true when the return value is greater than the specified value. So, when the user presses the D key the system gives it a return value of 1, and when pressing the m or e key it is 2 or 3. Because it is descending, set it as: if errorlevel 3 goto defrag should first test the highest error code
if errorlevel 2 goto mem
if errotlevel 1 goto end
弄花香满衣,掬水月在手。
明月鹭鸟飞, 芦花白马走。
我自一过后,野渡现横舟。
青云碧空在,净瓶水不流。
http://dos.e-stone.cn/guestbook/index.asp
======中國DOS聯盟=====
我的新网页http://rsds.7i24.com欢迎光顾
Floor 3 Posted 2003-05-12 00:00 ·  中国 上海 徐汇区 电信
初级用户
★★
DOS爱好者
Credits 478
Posts 100
Joined 2003-04-22 00:00
23-year member
UID 1648
Gender Male
Status Offline
I still don't quite understand it, but as long as I know it's not wrong that's fine
Learned from your teaching!

|||||||  寻人启示:姓名:
| c●● ~年龄:20,性别:男
|  ♂▃~ 特征:帅.很帅.酷.特别酷....
| |︺英俊潇洒.风流倜傥,玉树临风→我

单钓E时代论坛
Floor 4 Posted 2003-05-12 00:00 ·  中国 湖北 武汉 电信
元老会员
★★★★★
步行的人
Credits 9,654
Posts 3,351
Joined 2003-03-11 00:00
23-year member
UID 1113
Gender Male
From 湖北
Status Offline
Hehe...... just remember it first, and slowly come to understand it later...... go take a look at mys's "Ten Commandments of DOS" in the chatter section...
弄花香满衣,掬水月在手。
明月鹭鸟飞, 芦花白马走。
我自一过后,野渡现横舟。
青云碧空在,净瓶水不流。
http://dos.e-stone.cn/guestbook/index.asp
======中國DOS聯盟=====
我的新网页http://rsds.7i24.com欢迎光顾
Floor 5 Posted 2003-10-15 00:00 ·  中国 山东 烟台 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re Master Rushi:

The question raised by "Bozai" is correct: according to the content of choice, "choice /c:dme defrag,mem,end", when errorlevel >= 3, it should goto end, not goto defrag; likewise for errorlevel >= 1.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Forum Jump: