![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-13 04:55 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » Master Rushi, please come in: About your post "Batch Programming Tutorial" |
| Printable Version 1,425 / 4 |
| Floor1 柏仔 | Posted 2003-05-11 00:00 |
| 初级用户 Posts 100 Credits 478 | |
|
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 |
|
| Floor2 如是大师 | Posted 2003-05-12 00:00 |
| 元老会员 Posts 3,351 Credits 9,654 From 湖北 | |
|
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 |
|
| Floor3 柏仔 | Posted 2003-05-12 00:00 |
| 初级用户 Posts 100 Credits 478 | |
|
I still don't quite understand it, but as long as I know it's not wrong that's fine
Learned from your teaching! |
|
| Floor4 如是大师 | Posted 2003-05-12 00:00 |
| 元老会员 Posts 3,351 Credits 9,654 From 湖北 | |
|
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...
|
|
| Floor5 willsort | Posted 2003-10-15 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
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. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |