Specifications
132 Version 2.0
for
Usage
for %indexvar in set
command [arguments]
[command [arguments]]
…
endfor
for %indexvar run (start end [step])
command [arguments]
[command [arguments]]
…
endfor
Description
The for command executes one or more commands for each item in a set of items.
The set may be text strings or filenames or a mixture of both, separated by spaces (if
not in a quotation). If the length of an element in the set is between 0 and 256, and if
the string contains wildcards, the string will be treated as a file name containing
wildcards, and be expanded before command is executed.
If after expansion no such files are found, the literal string itself is kept. Indexvar is
any alphabet character from ‘a’ to ‘z’ or ‘A’ to ‘Z’, and they are case sensitive. It
should not be a digit (0-9) because %digit will be interpreted as a positional argument
on the command line that launches the script. The namespace for index variables is
separate from that for environment variables, so if indexvar has the same name as an
existing environment variable, the environment variable will remain unchanged by the
for loop.
Each command is executed once for each item in the set, with any occurrence of
%indexvar in the command replacing with the current item. In the second format of
for … endfor statement, indexvar will be assigned a value from start to end with an
interval of step. start and end can be any integer whose length is less than 7 digits
excluding sign, and it can also applied to step with one exception of zero. step is
optional, if step is not specified it will be automatically determined by following rule, if
start <= end then step = 1, otherwise step = -1. start, end and step are divided by
space.
Note
This command may only be used in scripts.
This command does not change the value of the environment variable lasterror.










