When you have SCAN with the WHILE condition, it starts from the current record. If you have SCAN (or SCAN with the FOR condition) it starts from the first record (if the set is ordered, it starts from the first record in the current order).
>Was just surprised when SCAN doesn't start with the first record but the current record. The intent was to examine all records.
>
>The code is:
>
>
>* cursor DTemporal is created with SELECT .... INTO CURSOR DTemporal READWRITE
>INDEX ON xxx TAG xxx
>...
>DELETE ALL FOR <condition> IN DTemporal
>* Several records are added. Current record is last one added.
>* The index has no effect on the order, at least as shown by BROWSE
>
>...
>
>SELECT DTemporal
>SET DELETED OFF
>* The intent is to examine all records
>SCAN
> IF DELETED()
>...
>ENDSCAN
>
>
>The solution in to add GO TOP, of course, but I sincerely expected the SCAN to start with the first record. Instead it started with the current record.
If it's not broken, fix it until it is.
My Blog