COMMAND NAME:

        FOR

USAGE:

        FOR ( <expr-1> ; <expr-2> ; <expr-3> ) <stmt>

        The FOR statement is a looping construct.  The FOR header contains
        up to three expressions.  <Expr-1> is the initial expression,
        <expr-2> is the test expression and <expr-3> is the terminal
        expression.  <Stmt> can be any SCL statement or command including a
        compound statement.

        The semantics of the FOR loop can be expressed with the WHILE loop.
        These two code fragments are equivalent, where e1, e2 and e3
        represent expressions and s represents a statement of arbitrary
        complexity:

                for ( e1; e2; e3) s

        is equivalent to

                e1
                while ( e2 )
                {
                    s
                    e3
                }

        Flow of control through a FOR statement is as follows.  First the
        initial expression is evaluated.  This expression is only evaluated
        once.  Next the test expression is evaluated.  If it evaluates to
        true, then the body of the loop (<stmt>) is executed.  Next the
        terminal expression is evaluated.  The process repeats from the
        point where the test expression is evaluated.  If the test
        expression evaluates to false then the loop is terminated.  The
        terminal expression is not evaluated when the test expression is
        false.

        All of the header expressions (<expr-1>, <expr-2> and <expr-2>) are
        optional.  If the test expression (<expr2) is omitted then the loop
        will iterate infinitely unless some other mechanism is used to
        terminate the loop (such as a BREAK statement or a keyboard
        interrupt).

EXAMPLE:

                for( ix=0; ix<MAX; ix++ )
                {
                    .
                    .

                }

        This is the SCL loop idiom for iterating a sequence of statements a
        fixed number of times.  The initial expression sets the control
        variable ix to 0.  Ix is checked to see if it is less than MAX.  If
        it is then the body of the loop is executed.  Finally, the terminal
        expression increments ix.  The body of the loop executes MAX times
        with the control variable ix varying from 0 to MAX-1.

SEE ALSO:

        DO
        WHILE
        CONTINUE
        BREAK
