DO WHILE ... ENDDO Command

Example   See Also

Executes a set of commands within a conditional loop.

Syntax

DO WHILE lExpression
  Commands
  [LOOP]
  [EXIT]
ENDDO

Arguments

lExpression

Specifies a logical expression whose value determines whether the commands between DO WHILE and ENDDO are executed. As long as lExpression evaluates to true (.T.), the set of commands are executed.

Commands

Specifies the set of Visual FoxPro commands to be executed as long as lExpression evaluates to true (.T.).

LOOP

Returns program control directly back to DO WHILE. LOOP can be placed anywhere between DO WHILE and ENDDO.

EXIT

Transfers program control from within the DO WHILE loop to the first command following ENDDO. EXIT can be placed anywhere between DO WHILE and ENDDO.

Remarks

Commands between DO WHILE and ENDDO are executed for as long as the logical expression lExpression remains true (.T.). Each DO WHILE statement must have a corresponding ENDDO statement.

Comments can be placed after DO WHILE and ENDDO on the same line. The comments are ignored during program compilation and execution.