Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.2 . The Guide To CA-Clippe - <b>do while</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 DO WHILE
 Execute a loop while a condition is true (.T.)
------------------------------------------------------------------------------
 Syntax

     [DO] WHILE <lCondition>
        <statements>...
        [EXIT]
        <statements>...
        [LOOP]
        <statements>...
     END[DO]

 Arguments

     <lCondition> is the logical control expression for the DO WHILE
     loop.

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

     LOOP branches control to the most recently executed DO WHILE or FOR
     statement.

 Description

     DO WHILE...ENDDO is a control structure that executes a block of
     statements repetitively, as long as <lCondition> evaluates to true (.T.).
     When the condition evaluates to true (.T.), control passes into the
     structure and proceeds until an EXIT, LOOP, or ENDDO is encountered.
     ENDDO returns control to the DO WHILE statement and the process repeats
     itself.  If an EXIT statement is encountered, control branches to the
     nearest ENDDO or NEXT statement.  If a LOOP statement is encountered,
     control branches to the nearest DO WHILE or FOR statement.  If the
     condition evaluates to false (.F.), the DO WHILE construct terminates and
     control passes to the statement immediately following the ENDDO.

     Use EXIT to terminate a DO WHILE structure based on a condition other
     than the DO WHILE condition.  LOOP, by contrast, prevents execution of
     statements within a DO WHILE based on an intermediate condition, and
     returns to the most recent DO WHILE statement.

     DO WHILE constructs may be nested within any other control structures to
     any depth.  The only requirement is that each control structure be
     properly nested.

 Examples

     .  This example demonstrates a typical control structure for a
        simple grouped report:

        LOCAL cOldSalesman, nTotalAmount
        USE Sales INDEX Salesman NEW
        DO WHILE .NOT. EOF()
           cOldSalesman := Sales->Salesman
           nTotalAmount := 0
           DO WHILE cOldSalesman = Sales->Salesman ;
              .AND. (.NOT. EOF())
              ? Sales->Salesman, Sales->Amount
              nTotalAmount := nTotalAmount + Sales->Amount
              SKIP
           ENDDO
           ? "Total: ", nTotalAmount, "for", cOldSalesman
        ENDDO
        CLOSE Sales

     .  This code fragment demonstrates how LOOP can be used to
        provide an intermediate processing condition:

        DO WHILE <lCondition>
           <initial processing>...
           IF <intermediate condition>
              LOOP
           ENDIF
           <continued processing>...
        ENDDO

     .  This example demonstrates the use of DO WHILE to emulate a
        repeat until looping construct:

        LOCAL lMore := .T.
        DO WHILE lMore
           <statements>...
           lMore := (<lCondition>)
        ENDDO

     .  This example uses a DO WHILE loop to move sequentially through
        a database file:

        DO WHILE .NOT. EOF()
           <statements>...
           SKIP
        ENDDO

See Also: BEGIN SEQUENCE DBEVAL() DO CASE FOR IF IF() RETURN

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