![]() |
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-09-23 16:43 |
47,812 topics / 349,917 posts / today 0 new / 48,274 members |
| DOS批处理 & 脚本技术(批处理室) » Please help me see what's wrong with this script, thanks |
| Printable Version 1,056 / 2 |
| Floor1 ziver | Posted 2006-06-04 08:00 |
| 初级用户 Posts 4 Credits 20 | |
|
I've just started learning batch files.
Why does this simple script jump to First every time? Friends who understand it, please help explain it, thanks. Also, could you introduce how choice return values work? |
|
| Floor2 electronixtar | Posted 2006-06-04 10:49 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
ErrorLevel x means a case greater than or equal to x! So you have to write it in reverse order!
if errorlevel 4 goto end if errorlevel 3 goto Third if errorlevel 2 goto Second if errorlevel 1 goto First This is the mistake beginners are most likely to make when writing ErrorLevel ^_^ Check the help yourself for how to use chioce! [ Last edited by electronixtar on 2006-6-4 at 10:51 ] |
|
| Floor3 220110 | Posted 2006-06-04 10:50 |
| 荣誉版主 Posts 313 Credits 718 | |
|
RE ziver :
A: Using this forum's search function instead of asking for help will save you a lot of waiting time, and you'll also be able to see more examples and understand more. B: Error codes should be tested starting from the highest value and going downward. if errorlevel 4 goto end C: If you don't use error codes for testing, you can test based on the character input by the user. See link {1} D: Related links: {1}http://www.cn-dos.net/forum/viewthread.php?tid=15763&fpage=1&highlight=choice {2}http://www.cn-dos.net/forum/viewthread.php?tid=6287&fpage=1&highlight=choice {3}http://www.cn-dos.net/forum/viewthread.php?tid=19414&fpage=1&highlight=choice {4}http://www.cn-dos.net/forum/viewthread.php?tid=5675&fpage=1&highlight=choice *************** Please change the thread title as soon as possible. Otherwise moderator willsort is going to dock your credits! Haha Suggested title: A question about the choice command and errorlevel *************** [ Last edited by 220110 on 2006-6-4 at 15:24 ] |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |