Condividi tramite


EXIT Command

Exits a DO WHILE, FOR, SCAN, or TRY…CATCH…FINALLY structure.

EXIT

Remarks

The EXIT command transfers control from within the structure to the command immediately following the structure.

Example

In the following example, the number of products in stock priced over 20 dollars is totaled in the DO WHILE loop until the end of the file (EOF) is encountered. The DO WHILE loop is exited and the total is displayed.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE products  && Opens Products table
SET TALK OFF
gnStockTot = 0

DO WHILE .T.     && Beginning of loop
   IF EOF( )
      EXIT
   ENDIF
   IF unit_price < 20
      SKIP
      LOOP
   ENDIF
   gnStockTot = gnStockTot + in_stock
   SKIP
ENDDO  && End of loop

CLEAR
? 'Total items in stock valued over 20 dollars:'
?? gnStockTot 

See Also

Reference

DO WHILE ... ENDDO Command

FOR EACH ... ENDFOR Command

FOR ... ENDFOR Command

SCAN ... ENDSCAN Command

TRY...CATCH...FINALLY Command

Other Resources

Commands (Visual FoxPro)

Language Reference (Visual FoxPro)