[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
+---------------------------------+
| DO WHILE |
+---------------------------------+
DO WHILE <expL>
<statements>
[LOOP]
[EXIT]
ENDDO
-----------------------------------
Executes commands inside loop while logical condition remains true.
-----------------------------------
In this structured programming command, a logical expression <expL> is
evaluated. As long as <expL> remains true the set of commands
(<statements> placed between DO WHILE and its matching ENDDO are
executed. Note that each DO WHILE must have a corresponding ENDDO
statement.
EXIT is a keyword which transfers program control from within the DO
WHILE loop to the first command following the ENDDO. EXIT may be placed
anywhere between DO WHILE and ENDDO.
LOOP is a keyword which may be placed anywhere between DO WHILE and
ENDDO. LOOP returns program control directly back to the DO WHILE.
Note that comments may be placed after DO WHILE and ENDDO on the same
line - the comments are ignored during program compilation and
execution.
In the following program example, the total payments for the month of
July are totaled in the DO WHILE loop until the EOF (end-of-file) is
encountered. The DO WHILE loop is exited and the total is printed on
the screen.
Clauses
-------
<expL>
As long as <expL> remains true, statements between DO WHILE and its
matching ENDDO are executed.
<statements>
FoxPro commands to be executed.
LOOP
Returns program control directly back to DO WHILE.
EXIT
Transfers program control from in DO WHILE loop to first command
following ENDDO.
+---------------------------------+
| Program Example |
+---------------------------------+
In this example, total payments for month of July are totaled in DO
WHILE loop until EOF is encountered. DO WHILE loop is exited and total
is printed on screen.
SET TALK OFF
USE payments
julytot = 0
DO WHILE .T. You can place comments here!
IF EOF()
EXIT
ENDIF
IF CMONTH(DATE) <> 'July'
SKIP
LOOP
ENDIF
julytot = julytot + amount
SKIP
ENDDO Or you can place comments here!
? 'Total of payments for July is '
?? julytot
-----------------------------------
See Also: DO CASE, IF ... ENDIF, IIF(), FOR ... ENDFOR, SCAN
-----------------------------------
See Also:
DO CASE
IF ... ENDIF
IIF()
FOR ... ENDFOR
SCAN
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson