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:请访问
批处理编程的异类 ,欢迎交流与共享批处理编程心得!