Data editing > Flow control > Loops > do with individually specified numeric values
 
do with individually specified numeric values
Quick reference
To define a loop to be repeated for a set of given values, type:
do label_number int_variable=(val1,val2, ... )
More information
The simplest way to define the values for the loop is to list them individually. In this case, values must be whole numbers, separated by commas with the whole list enclosed in parentheses. For example:
do 20 t5 = (125,130,140,145)
if (c(t5,t5+4).gt.3000) c(t5,t5+4)=$ $
20 continue
The do statement indicates three things:
the loop is terminated by the statement labeled 20
the integer variable to be used is t5
the statements within the loop are to be repeated four times (there are four values in the list).
The statement labeled 20 is continue which just sends Quantum back to do.
The purpose of this loop is to check whether the contents of four fields are greater than 3000, and if so to reset those columns to blank. The first time through the loop, t5=125. When substituted into the if statement it yields:
if (c(125,129).gt.3000) c(125,129)=$ $
The next statement is continue which goes back to the top of the loop. t5 is now pointing to the second value in the list, 130. The if statement reads:
if (c(130,134).gt.3000) c(130,134)=$ $
This process is repeated until t5 has taken all values in the list. There is no need to include statements which check the value of t5 and jump out of the loop when the last value is reached: Quantum keeps a count of how many values there are and it knows that once the last value has been reached it should continue with the statements following the loop.
See also
Loops