SCAN ... ENDSCAN Command
Moves the record pointer through the currently selected table and executes a block of commands for each record that meets the specified conditions.
SCAN [NOOPTIMIZE] [Scope] [FOR lExpression1] [WHILE lExpression2] [Commands] [LOOP] [EXIT] ENDSCAN |
Parameters
- NOOPTIMIZE
-
Prevents Rushmore Query Optimization of SCAN.
For more information, see SET OPTIMIZE Command and Using Rushmore Query Optimization to Speed Data Access.
- Scope
-
Specifies a range of records to be scanned. Only the records within the range are scanned. The scope clauses are: ALL, NEXT nRecords, RECORD nRecordNumber, and REST. For more information on scope clauses, see the Scope Clauses online topic.
The default scope for SCAN is all records (ALL).
- FOR lExpression1
-
Executes commands only for records for which lExpression1 evaluates to true (.T.). Including the FOR clause lets you filter out records you don't want scanned.
Rushmore optimizes a query created with SCAN ... FOR if lExpression1 is an optimizable expression. For best performance, use an optimizable expression in the FOR clause.
For more information, see SET OPTIMIZE Command and Using Rushmore Query Optimization to Speed Data Access.
- WHILE lExpression2
-
Specifies a condition whereby the commands are executed for as long as lExpression2 evaluates to true (.T.).
- Commands
-
Specifies the Visual FoxPro commands to be executed.
- LOOP
-
Returns control directly back to SCAN. LOOP can be placed anywhere between SCAN and ENDSCAN.
- EXIT
-
Transfers program control from within the SCAN ... ENDSCAN loop to the first command following ENDSCAN. EXIT can be placed anywhere between SCAN and ENDSCAN.
- ENDSCAN
-
Indicates the end of the SCAN procedure.
Remarks
Example
See Also
© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic
Microsoft Visual FoxPro 9 SP2 Help file, VFPX Edition v1.08