LOOP / REPEAT

LOOP / REPEAT

Top  Previous  Next

 

The LOOP statement introduces a sequence of statements to be executed repeatedly.

 

 

Format

 

LOOP

{statement(s)}

{WHILE expr}

{UNTIL expr}

{statement(s)}

REPEAT

 

where

 

statement(s)are statements to be executed within the loop.

 

expris an expression which can be resolved to a numeric value

 

 

There may be any number of WHILE or UNTIL statements within the loop appearing at any position relative to other statements.

 

Execution of the statements within the loop continues repeatedly until either the expression associated with a WHILE statement evaluates to zero or the expression associated with an UNTIL statement evaluates to a non-zero value.

 

The loop may also be terminated by an EXIT statement as detailed in its own description.

 

The CONTINUE statement may be used to commence the next iteration of the loop without execution of any intervening statements.

 

 

Example

 

LOOP

  REMOVE ITEM FROM ITEM.LIST SETTING MORE

  DISPLAY "Item id " : ITEM

WHILE MORE

REPEAT

 

This program fragment displays the elements of the dynamic array ITEM.LIST.

 

 

See also:

CONTINUE, EXIT, FOR/NEXT, WHILE, UNTIL