Iterated DO construct

The iterated DO construct takes the form:

DO variable=start_value, end_value [, increment]
  statement_block
END DO

This is equivalent to:

 variable=start_value
 DO WHILE(variable <= end_value)
  statement_block
  variable=variable+increment
 END DO

DO constructs can be named.

variable is an INTEGER variable, whilst start_value, end_value, and increment are INTEGER expressions. increment is optional and when omitted defaults to 1 (unity). increment may be negative in which case start_value>end_value. For example:

DO i=10,0,-2
  !Do something for i=10,8,6,4,2 and 0
END DO

EXIT and CYCLE can be used with all forms of the DO construct.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited