Silverfrost Logo About Us | Contact Us
 

DO construct

There are two forms for the DO construct. The simple DO construct described here and the iterated DO construct described in the next topic.

A simple DO construct takes the form:

DO 
  statement_block
END DO

This causes the block of statements to be repeated. Typically, within the block of statements, there will be an IF statement of the form:

IF(logical_expression) EXIT

The EXIT statement causes control to pass to the statement following END DO.

The CYCLE statement is an alternative to EXIT. It causes control to pass to a point immediately after the last statement of the block, allowing repetition to continue.

DO constructs can be named. If a DO construct is named then the same name must be appended to the corresponding END DO and may optionally be appended to an enclosing EXIT or CYCLE. If DO constructs are nested, one within another, then a name attached to EXIT or CYCLE provides an extra degree of control.

A DO WHILE construct provides an alternative construction in the form:

DO WHILE(logical_expression)
  statement_block
END DO

This is equivalent to:

DO
  IF(.NOT.logical_expression) EXIT
  statement_block
END DO

 

 

Copyright © 1999-2017 Silverfrost Limited