Visual FoxPro Scan command

FoxPro has an unusual type of loop specifically for processing data in tables. The Scan loop steps through the a recordset and executes the statements in the loop body for each record. Its simplest form is equivalent to a While loop:

* Move to first record then loop until we hit end of file
Go Top
Do While Not Eof()
  * Process this record
  Skip          && Move to next record

This is however more flexible than a While loop because the Scan can accept a For clause which will select which records are to be processed. The loop statement below will only process those records where the cost field is greater than 1,000:

Scan For cost > 1000

Case  | s Loops  |  For

More tips from Alvechurch Data

More tips from Alvechurch Data

FoxPro Gotcha

Common mistakes that we all make in Visual FoxPro.

Read More

FoxPro 101 - Scan ... EndScan loop

Visual FoxPro Tutorial - Using a scan loop to control program flow.

Read More

Scan loop in Visual FoxPro

Process each record in a table with a FoxPro Scan loop.

Read More