Share via


EXIT (Comando)

Sale de un bucle DO WHILE, FOR o SCAN.

EXIT

Observaciones

EXIT transfiere el control desde dentro de un bucle DO WHILE ... ENDDO, FOR ... ENDFOR, o SCAN ... ENDSCAN al comando que sigue inmediatamente a ENDDO, ENDFOR, o ENDSCAN.

Ejemplo

En el ejemplo siguiente se calcula el número de productos en existencias cuyo precio es superior a 20 dólares mediante el bucle DO WHILE hasta llegar al final del archivo (EOF). Se sale del bucle DO WHILE y se muestra el total.

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 

Vea también

DO WHILE ... ENDDO | FOR EACH ... ENDFOR | SCAN ... ENDSCAN