LOOP / REPEAT

LOOP / REPEAT

Top  Previous  Next

 

The LOOP and REPEAT commands define the top and bottom of a group of sentences to be repeated within a paragraph.

 

 

Format

 

LOOP

    sentence(s)

REPEAT

 

where

 

sentence(s)are the sentence(s) to be executed within the loop.

 

 

The LOOP and REPEAT statements surround one or more sentences to be repeated. The loop continues until the paragraph terminates by use of STOP or ABORT, something run by the paragraph causes an abort event, or a GO statement is used to leave the loop.

 

Loops may be nested to any depth. Each REPEAT statement is paired with a corresponding LOOP statement and is equivalent to a GO statement that allows backward jumps to a label at the position of the LOOP statement. The behaviour of paragraphs that branch into or out of loops can be determined by this label and GO equivalent.

 

The keywords LOOP and REPEAT are recognised by the paragraph pre-processor and not via the VOC and hence cannot be replaced by alternative words.

 

 

Example

 

PA

LOOP

  IF <<A,File to delete>> = "" THEN GO DONE

  DELETE.FILE <<File to delete>>

REPEAT

DONE:

 

This paragraph prompts for names of files to delete until a blank line is entered. Note the need for the A control option on the first inline prompt in the loop so that the prompt is repeated on each cycle.

 

Because the DONE label is at the end of the paragraph, the above example could alternatively be written as

 

PA

LOOP

  IF <<A,File to delete>> = "" THEN STOP

  DELETE.FILE <<File to delete>>

REPEAT