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-05 02:24
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Do batch files execute completely in DOS command order? View 984 Replies 4
Original Poster Posted 2003-11-15 00:00 ·  中国 四川 成都 教育网
初级用户
Credits 108
Posts 2
Joined 2003-11-15 00:00
22-year member
UID 12863
Gender Male
Status Offline
I'm a DOS beginner, and I want to start with batch files. I don't know whether it's easy to learn...
Floor 2 Posted 2003-11-15 00:00 ·  中国 湖北 武汉 江夏区 电信
元老会员
★★★★★
步行的人
Credits 9,654
Posts 3,351
Joined 2003-03-11 00:00
23-year member
UID 1113
Gender Male
From 湖北
Status Offline
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..
弄花香满衣,掬水月在手。
明月鹭鸟飞, 芦花白马走。
我自一过后,野渡现横舟。
青云碧空在,净瓶水不流。
http://dos.e-stone.cn/guestbook/index.asp
======中國DOS聯盟=====
我的新网页http://rsds.7i24.com欢迎光顾
Floor 3 Posted 2003-11-17 00:00 ·  中国 江西 宜春 万载县 电信
初级用户
Credits 153
Posts 11
Joined 2003-10-21 00:00
22-year member
UID 11637
Gender Male
Status Offline
Wow,,, an expert has arrived..~
Floor 4 Posted 2003-11-19 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 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
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 5 Posted 2003-12-06 00:00 ·  中国 广东 广州 教育网
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
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)


Forum Jump: