Many Xbase commands have a scope option (not to be confused with the scope resolution operator) that dictates which records to process. The scope honors the current index order, filter, and key constraints. Three clauses comprise a commandís scope:

<scope>

FOR <for condition>

WHILE <while condition>

There are four different options for <scope>:

ALL

All records, starting with the first.

REST

Starting with the current record, processes all subsequent records in the table

NEXT <expN>

Starting with the current record, processes the next <expN> records. NEXT 1 processes the current record only.

RECORD <bookmark>

The individual record referenced by the bookmark <bookmark>. You may also specify a record number for DBF tables.

Different commands have different default scopes. In conjunction with <scope>, many commands have one or both of the following conditional clauses:

FOR <for condition>

Specifies a condition that must evaluate to true for each record to be processed. If the <for condition> fails, that record is skipped and the next record is tested.

WHILE <while condition>

Specifies a condition that must evaluate to true for processing to continue. The test is performed before processing each record. If the <while condition> fails, processing stops.

If you specify a FOR clause, the default scope of the command becomes ALL. If you specify a WHILE clause, with or without a FOR clause, the default scope of the command becomes REST.