next up previous contents
Next: Examples of Loop Counts Up: Control Constructs Previous: DO ... WHILE Loops

 

Indexed DO Loops

Loops can be written which cycle a fixed number of times. For example,

    DO i1 = 1, 100, 1
      ... ! i is 1,2,3,...,100
      ... ! 100 iterations
    END DO

The formal syntax is as follows,

 
DO < DO-var >=< expr1 >,< expr2 > [ ,< expr3 > ]
  
		 < exec-stmts >

END DO

The number of iterations, which is evaluated before execution of the loop begins, is calculated as

 
MAX(INT((< expr2 >-< expr1 >+< expr3 >)/< expr3 >),0)

If this is zero or negative then the loop is not executed.

If < expr3 > is absent it is assumed to be equal to 1.

For more information, click here gif


next up previous contents
Next: Examples of Loop Counts Up: Control Constructs Previous: DO ... WHILE Loops

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.