Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>for...next</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
FOR...NEXT


Syntax:     FOR <memvar> = <expN1> TO <expN2> [STEP <expN3>]
               <statements>...
               [EXIT]
               <statements>...
               [LOOP]
            NEXT

Purpose:    To loop for a range either incrementing or decrementing the
            range expression.

Arguments:  <memvar> is the loop control variable.

            <expN1> is the initial value assigned to the control
            variable and the lower boundary of the looping range.

            <expN2> is the upper boundary of the looping range.

Options:    Step: The STEP clause sets the increment of the control
            variable to <expN3>.  If no STEP clause is specified, the
            default increment is one.

            Exit: The EXIT statement unconditionally branches
            control from within a FOR...NEXT or DO WHILE structure to
            the statement immediately following the matching NEXT or
            ENDDO statement.

            Loop: The LOOP statement branches control to the most
            recently executed FOR...NEXT or DO WHILE.

Usage:      FOR...NEXT allows you to loop from an initial value of a
            control variable to some upper boundary moving through the
            range of values of the control variable for a specified
            increment.  Note that all expressions in the FOR statement
            are reevaluated for each loop.  The upper boundary and
            increment are dynamic, therefore, and can be changed as the
            construct operates.

Library:    CLIPPER.LIB


----------------------------------- Examples -------------------------------

   The FOR...NEXT construct is most useful for traversing arrays.  For
   example:

   * To walk forward through an entire array.
   len_array = LEN(array)
   FOR i = 1 TO len_array
      <statements>...
   NEXT

   * To walk backwards through an entire array.
   len_array = LEN(array)
   FOR i = len_array TO 1 STEP -1
      <statements>...
   NEXT


See Also: DO CASE DO WHILE IF

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson