![]() |
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-30 17:22 |
47,813 topics / 349,918 posts / today 0 new / 48,279 members |
| DOS学习入门 & 精彩文章 (教学室) » Do batch files execute completely in DOS command order? |
| Printable Version 1,169 / 4 |
| Floor1 冰寅 | Posted 2003-11-15 00:00 |
| 初级用户 Posts 2 Credits 108 | |
|
I'm a DOS beginner, and I want to start with batch files. I don't know whether it's easy to learn...
|
|
| Floor2 如是大师 | Posted 2003-11-15 00:00 |
| 元老会员 Posts 3,351 Credits 9,654 From 湖北 | |
|
It's not hard.. Batch files execute in sequence according to the order you write them.
So each line in a batch command can only have one command.. |
|
| Floor3 zovusazm | Posted 2003-11-17 00:00 |
| 初级用户 Posts 11 Credits 153 | |
|
Wow,,, an expert has arrived..~
|
|
| Floor4 willsort | Posted 2003-11-19 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re zovusazm:
Similar to high-level compiled languages, batch processing also has three execution structures: sequential structure, loop structure, and selection structure. In most batch file applications, the sequential structure is more common, that is, "execute in sequence according to the order you write them." Of course, for slightly more complex applications, selection structures like IF and loop structures like FOR are also used. However, in advanced applications, the structure often used is GOTO, which is more or less the same as GOTO in BASIC. This is also a common structure in all interpreted languages. It is used to implement large-range loop structures or selection structures, that is, loops or selections spanning more than one line. For example: Multi-statement form of selection IF: IF == GOTO CHOOSE_A IF == GOTO CHOOSE_B :CHOOSE_A REM statement block corresponding to choice A GOTO END :CHOOSE_B REM statement block corresponding to choice B GOTO END :END Multi-statement form of loop FOR: SET CONIDITION= SET BOUND=~~~~~~ REM This loop executes 5 times; the boundary above can be flexibly controlled as long as it meets the condition. :LOOP IF == GOTO END REM statement block inside the loop. SET CONIDITION=~%CONDITION% :END |
|
| Floor5 GOTOmsdos | Posted 2003-12-06 00:00 |
| 铂金会员 Posts 1,827 Credits 5,154 | |
|
In batch processing, one line is not limited to one command.
For example, a command1 & command2 & command3 ... (no matter whether the previous command fails, the following ones are still executed) b command1 && command2 && command3....(the following ones are executed only if the previous command succeeds) c command1 || command2|| command3.... (the following ones are executed only if the previous command fails) These multi-command forms helped me solve some thorny problems! There's also the pipe symbol for connecting front and back: | program1 | program2 Also, filtering: command | find (search) command |more (paged display) command |sort (sort) |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |