forlang.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DO
                                             Up Contents Index Back
─────DO─────────────────────────────────────────────────────────────────────
 
     Action
 
     Repeatedly executes the statements following the DO statement
     through the end of the loop.
 
     Syntax
 
     DO [label [,] ] dovar = start, stop [, inc]
 
     Parameter        Description
 
     label            The statement label of an executable statement.
 
     dovar            An integer, real, or double-precision variable.
 
     start, stop      The integer, real, or double-precision
                      expressions.
 
     inc              A nonzero increment for the DO variable
                      (defaults to one).
 
     Remarks
 
     The <label> is optional. If <label> is used, the loop terminates
     with the labeled statement. If <label> is not used, the loop is
     terminated with an END DO statement.
 
     The range of a DO loop begins with the statement immediately
     following the DO statement and includes the terminal statement
     of the DO loop.
 
     Execution of a CALL statement that is in the range of a DO
     loop does not terminate the DO loop unless an alternate-return
     specifier in a CALL statement returns control to a statement
     outside the DO loop.
 
     Restrictions on DO loops:
 
         ■  Other statement blocks or loops, such as SELECT CASE blocks
            or DO WHILE loops must either entirely contain a DO loop or
            be entirely contained in a DO loop.
 
         ■  The DO variable may not be modified by statements within
            the loop.
 
         ■  Jumping into a DO loop from outside its range is not
            permitted.
 
         ■  Two or more DO or DO WHILE loops may share one
            labeled terminal statement. An END DO statement may
            terminate only one DO or DO WHILE loop.
 
     The number of iterations in a DO loop is limited to the maximum
     possible value of the loop variable.
 
     See Also: $DO66
 
     Examples
 
     The following two program fragments are examples of DO statements:
 
     C     Initialize the even elements of a 20-element real array
           DIMENSION array(20)
           DO 100 j = 2, 20, 2
       100 array(j) = 12.0
 
     C     Perform a function 11 times
           DO 200,  k = -30, -60, -3
              int =  j / 3
              isb = -9 - k
              array(isb) = MyFunc (int)
       200 CONTINUE
 
     The following shows the final value of a DO variable (in this case
     11):
 
           DO 200 j = 1, 10
       200 WRITE (*, '(I5)') j
           WRITE (*, '(I5)') j
                                    -♦-