[Next] [Up] [Previous]

The REPEAT Statement

The REPEAT statement has the form

       REPEAT statement-number

where statement-number is the statement number of a FOR statement not containing a sequence argument. The REPEAT statement adds that FOR statement's increment to its intvar, and transfers control to the statement after the FOR statement if either:

Otherwise, fall-through to the next statement is made.

Multiple REPEAT statements referring to the same FOR statement are possible; since fall-through out of any one of them means that the loop has ended, the programmer is expected to position them so that it is not possible to encounter the other REPEAT statement after falling through one of them.

It is important to note that, for example, the statements

     7 FOR I=1,5
intervening statements
       REPEAT 7

are EXACTLY equivalent to the statements

     7 . I=1
intervening statements
       IF I .LE 5, 10007

except for the fact that the label 10007 is not defined in the former case. That is, there are NO restrictions on branching out of, then back into, a FOR loop. As for modifying the value of a FOR loop parameter, the compiler may utilize a register copy of that parameter only if there is no apparent attempt to modify the parameter explicitly. Thus, modifying the parameter using _ADR and _MEM (as a left-hand function) would have unexpected results, but any conventional attempt to modify the loop parameter is allowed. Note that if there is branching in or out of the loop, the compiler may simply assume that a register copy of the parameter may not be used, as the period-alternative construct (see the description of the IF statement above) makes efficient handling of extended ranges unneccessary.

A REPEAT statement can also have the statement number of a GET statement as its object. For the description of the use of the GET and REPEAT statements, refer to the section concerning subprograms (as the GET statement concerns argument passing, it is described there instead of separately).

[Next] [Up] [Previous]