As noted above, the DO command works basically within command files, although there is an interactive-level form which has basically the same structure. Within a command file, the DO command has two prompts:
It will then loop over everything that follows until it finds an ENDDO command,
starting with the user-defined variable set to n1, and incrementing by n3 until
it is greater than n2. If you forget to put the ENDDO in, the DO loop should
exit at the end of the command file (it is not necessary to insert the ENDDO
yourself in interactive mode; it is done for you when you hit
^Z to end insert mode).
Note again that DO is a standard command, and thus n1, n2, n3 may be given as
integer values, defaults (including #) or arithmetic expressions. n3 will be
defaulted to
if omitted, depending on whether n2 is
or
n1. If n2 is also
omitted it defaults to n1 (trivial case) and the loop is executed once only. DOs
may be nested to a depth of 16.
Example:
! Command file to test DO construct
declare n i4
clear-stack
do n 1 10
read-spectrum n
average
enddo