> SET Confirm Off
> PUBLIC Code1, Ok, Vou_no1
> Vou_no1 = 0
> CLOSE All
> USE gin_reg
> SORT On Date To temp
> USE temp
> COPY To gin_reg
> CLOSE All
> USE In 0 gin_reg
> USE In 0 sallint Index sallint
> USE In 0 avlbook
>
From the VFP on-line help for the Sort Command:
Sorts records in the currently selected table and outputs the sorted records to a new table.
SORT TO TableName ON FieldName1 [/A | /D] [/C]
[, FieldName2 [/A | /D] [/C] ...] [ASCENDING | DESCENDING]
[Scope] [FOR lExpression1] [WHILE lExpression2]
[FIELDS FieldNameList | FIELDS LIKE Skeleton
| FIELDS EXCEPT Skeleton] [NOOPTIMIZE]
Parameters
TableName
Specifies the name of the new table containing the sorted records. Visual FoxPro assumes a .dbf file name extension for tables. A .dbf extension is automatically assigned if the file name you include doesn't have an extension.
ON FieldName1
Specifies the field in the currently selected table on which the sort is based. The contents and data type of the field determine the order of the records in the new table. By default, the sort is done in ascending order. You can't sort on memo or general fields.
So, as you can see, this code is physically copying all the records from gin_reg and physically sorting them by date by outputing them in sorted order to temp.dbf. It is then copying all the records back into the gin_reg table.
So if the application happens to be running a little too quickly and the goal is to slow it down a little bit, this is a very good approach.
Otherwise, I would simply create an index on the date field and set the ordewr using that.