UNTIL

UNTIL

Top  Previous  Next

 

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

 

 

Format

 

UNTIL expr

 

where

 

exprevaluates to a numeric value

 

 

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

 

IF expr # 0 THEN EXIT

 

If the CONDITIONAL.STATEMENTS option of the $MODE compiler directive is active, expr may be one of the following statements that in its normal form has a THEN/ELSE clause:

FILELOCK, FILEUNLOCK, FIND, FINDSTR, FLUSH, GETLIST, LOCATE, MATREAD, MATREADCSV, MATREADL, MATREADU, OPEN, OPENPATH, OPENSEQ, OSREAD, READ, READBLK, READCSV, READL, READLIST, READNEXT, READSEQ, READU, READV, READVL, READVU, SEEK, WRITEBLK, WRITECSV, WRITESEQ

 

When used in this way, the LOCKED or ON ERROR clauses normally associated with some of these statements are not available.

 

 

Examples

 

FOR I = 1 TO 20

UNTIL A(I) < 0

  DISPLAY A(I)

NEXT I

 

This program fragment displays elements of matrix A. The loop terminates if an element is found with a negative value.

 

 

LOOP

UNTIL OSREAD 'C:\FAX.DATA'

  SLEEP 300

REPEAT

 

The above program fragment, which requires the CONDITIONAL.STATEMENTS option of the $MODE compiler directive to be active, repeatedly attempts to read the C:\FAX.DATA file at five minute intervals. When successful, the loop exits.

 

 

See also:

EXIT, WHILE