Next: , Previous: DO IF, Up: Conditionals and Looping



11.3 DO REPEAT

     DO REPEAT repvar_name=expansion....
             ...
     END REPEAT [PRINT].
     
     expansion takes one of the following forms:
             var_list
             num_or_range...
             'string'...
     
     num_or_range takes one of the following forms:
             number
             num1 TO num2

DO REPEAT repeats a block of code, textually substituting different variables, numbers, or strings into the block with each repetition.

Specify a repeat variable name followed by an equals sign (=) and the list of replacements. Replacements can be a list of variables (which may be existing variables or new variables or a combination thereof), of numbers, or of strings. When new variable names are specified, DO REPEAT creates them as numeric variables. When numbers are specified, runs of integers may be indicated with TO notation, for instance 1 TO 5 and 1 2 3 4 5 would be equivalent. There is no equivalent notation for string values.

Multiple repeat variables can be specified. When this is done, each variable must have the same number of replacements.

The code within DO REPEAT is repeated as many times as there are replacements for each variable. The first time, the first value for each repeat variable is substituted; the second time, the second value for each repeat variable is substituted; and so on.

Repeat variable substitutions work like macros. They take place anywhere in a line that the repeat variable name occurs as a token, including command and subcommand names. For this reason it is not a good idea to select words commonly used in command and subcommand names as repeat variable identifiers.

If PRINT is specified on END REPEAT, the commands after substitutions are made are printed to the listing file, prefixed by a plus sign (+).