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-06 15:02
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » About the choice command View 3,958 Replies 17
Original Poster Posted 2003-08-16 00:00 ·  中国 浙江 杭州 余杭区 电信
中级用户
★★
Credits 411
Posts 78
Joined 2003-07-27 00:00
22-year member
UID 7622
Gender Male
Status Offline
The return code of the choice command is arranged in the order of the specified options. For example, in choice /c:dme defrag,mem,end, the return code for 'd' (defrag) is 1, the return code for'm' (mem) is 2, and the return code for 'e' (end) is 3. If you swap the order, the return code will change. For example, in choice /c:dem defragend,mem, the return code for 'd' (defragend) is 1, the return code for 'e' (end) is 2, and the return code for'm' (mem) is 3.
Floor 2 Posted 2003-08-16 00:00 ·  中国 浙江 杭州 电信
中级用户
★★
Credits 411
Posts 78
Joined 2003-07-27 00:00
22-year member
UID 7622
Gender Male
Status Offline
Why is there no one to help me?
Floor 3 Posted 2003-08-16 00:00 ·  中国 香港 有线电视
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
The following is a quote from hotdog on 2003-8-16 3:12:22:
What is the order of the return codes for the choice command, like 1234...
For example, choice /c:dme defrag,mem,end
Which return code is 1
Which is 2
Which is 3
Does swapping the order change the return codes?
For example, choice /c:dem defrag,end,mem
Which brother can help answer?

choice /c:dem defrag,end,mem
^----Return code is 1
^---Return code is 2
^--Return code is 3
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 4 Posted 2003-08-16 00:00 ·  中国 浙江 杭州 余杭区 电信
中级用户
★★
Credits 411
Posts 78
Joined 2003-07-27 00:00
22-year member
UID 7622
Gender Male
Status Offline
Then why is it written like this? Can you explain it?
@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto defrag
if errorlevel 2 goto mem
if errotlevel 1 goto end
Floor 5 Posted 2003-08-16 00:00 ·  中国 广东 肇庆 电信
高级用户
★★
Credits 578
Posts 135
Joined 2003-07-10 00:00
22-year member
UID 6709
Gender Male
Status Offline
It's just that writing it like this is clearer!

You can write it like this:
choice /c:dme d,m,e
It can also be written like this:
choice /c:dme

The result is the same!
Floor 6 Posted 2003-08-16 00:00 ·  中国 广东 肇庆 电信
高级用户
★★
Credits 578
Posts 135
Joined 2003-07-10 00:00
22-year member
UID 6709
Gender Male
Status Offline
It's just that the prompts on the screen are different!
Floor 7 Posted 2003-08-16 00:00 ·  中国 香港 有线电视
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
The following is a quote from hotdog on 2003-8-16 16:46:38:
Then may I ask why it is written like this
Can you explain it
@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto defrag
if errorlevel 2 goto mem
if errotlevel 1 goto end


You made a mistake.....
It should be like this:

@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto end
if errorlevel 2 goto mem
if errotlevel 1 goto defrag
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 8 Posted 2003-08-16 00:00 ·  中国 广东 肇庆 电信
高级用户
★★
Credits 578
Posts 135
Joined 2003-07-10 00:00
22-year member
UID 6709
Gender Male
Status Offline
The following is the speech of Roy on 2003-8-16 17:02:12:
The following is the speech of hotdog on 2003-8-16 16:46:38:
Then, may I ask why it is written like this
Can you explain it
@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto defrag
if errorlevel 2 goto mem
if errotlevel 1 goto end


You made a mistake.....
It should be like this:

@echo off
choice /c:dme defrag,mem,end
if errorlevel 3 goto end
if errorlevel 2 goto mem
if errotlevel 1 goto defrag



Hehe! I didn't pay attention either;

Floor 9 Posted 2003-08-16 00:00 ·  中国 重庆 电信
银牌会员
★★★
Credits 2,202
Posts 499
Joined 2003-06-12 00:00
23-year member
UID 4876
Gender Male
Status Offline
Please clarify your specific context. The "if errorlevel 3 goto end" in batch scripting means if the error level of the previous command is greater than or equal to 3, then jump to the label "end". But without the full context of the surrounding batch code, it's hard to be more precise about which specific command's error it refers to. But based on the general syntax, that's the basic meaning. Please provide more context if possible.
一年四季,枫叶红了又红;人生四季,失去的,还能再来吗?—— !
Floor 10 Posted 2003-08-16 00:00 ·  中国 湖南 湘潭 电信
高级用户
★★
Credits 871
Posts 269
Joined 2003-07-02 00:00
23-year member
UID 6298
Gender Male
Status Offline
If the choice is 3, then execute end
Floor 11 Posted 2003-08-16 00:00 ·  中国 浙江 杭州 余杭区 电信
中级用户
★★
Credits 411
Posts 78
Joined 2003-07-27 00:00
22-year member
UID 7622
Gender Male
Status Offline
I see. Thanks.
Floor 12 Posted 2003-08-16 00:00 ·  中国 重庆 电信
银牌会员
★★★
Credits 2,202
Posts 499
Joined 2003-06-12 00:00
23-year member
UID 4876
Gender Male
Status Offline
The following is a quote from zl7322 on 2003-8-16 22:42:11:
If you choose 3, it will execute end

Where is this 3 chosen? Isn't batch processing executed sequentially?
一年四季,枫叶红了又红;人生四季,失去的,还能再来吗?—— !
Floor 13 Posted 2003-08-17 00:00 ·  中国 浙江 杭州 电信
中级用户
★★
Credits 411
Posts 78
Joined 2003-07-27 00:00
22-year member
UID 7622
Gender Male
Status Offline
Floor 14 Posted 2004-06-24 00:00 ·  中国 广东 广州 联通
中级用户
★★
Credits 378
Posts 88
Joined 2004-05-05 00:00
22-year member
UID 23815
Gender Male
Status Offline
Been looking for this!
www.51ct.net
Floor 15 Posted 2004-06-24 00:00 ·  中国 黑龙江 大庆 大庆中基石油通信建设有限公司
初级用户
Credits 106
Posts 1
Joined 2004-06-21 00:00
22-year member
UID 27170
Gender Male
Status Offline
What does the choice command mean
Forum Jump: