WHILE

Top  Previous  Next

 

The WHILE statement is used in conjunction with the FOR / NEXT or LOOP / REPEAT constructs to determine whether execution of the loop should continue.

 

 

Format

 

WHILE expr

 

where

 

exprevaluates to a numeric value

 

 

The WHILE statement causes execution of the innermost FOR/NEXT or LOOP/REPEAT construct to terminate if the value of expr is zero. It is equivalent to a statement such as

 

IF expr = 0 THEN EXIT

 

 

Example

 

LOOP

  REMOVE ITEM FROM LIST SETTING DELIMITER

  DISPLAY ITEM

WHILE DELIMITER

REPEAT

 

This program fragment displays items removed from dynamic array LIST. The loop is terminated when the value of DELIMITER becomes zero.

 

 

See also:

EXIT, UNTIL