Scatter, Gather
These commands were part of every application we wrote in FoxPro 2.x (and even in earlier versions). We don't use them the same way in Visual FoxPro because VFP's buffering capabilities make it unnecessary, but one VFP-only version of the commands can be useful.SCATTER copies all or part of a record to an array, memory variables or an object. GATHER collects data from an array, variables or an object and sticks it in the current record.
Usage |
SCATTER [ FIELDS FieldList | [ LIKE Skeleton1 ] [ EXCEPT Skeleton2 ] ] MEMVAR | TO ArrayName | NAME ObjectName [ MEMO ] [ BLANK ] GATHER [ FIELDS FieldList | [ LIKE Skeleton1 ] [ EXCEPT Skeleton2 ] ] MEMVAR | FROM ArrayName | NAME ObjectName [ MEMO ] |
Parameter |
Value |
Meaning |
FieldList |
List of fields |
The fields to include in the command. |
Skeleton1 |
Fieldname with wildcards |
A specification for which fields to include in the command. Wildcards are * and ?. |
Skeleton2 |
Fieldname with wildcards |
A specification for which fields to exclude from the command. Wildcards are * and ?. |
ArrayName |
Name |
An array to hold the scattered data or from which to get the gathered data. SCATTER creates or enlarges the array, as needed, but doesn't shrink it. |
ObjectName |
Name |
An object that has a property corresponding to each specified field. SCATTER creates the object. |
Example |
* Create an object corresponding to a Customer record * Assumes the record pointer is on the relevant customer SCATTER NAME oCust MEMO * Now you can refer to the fields as properties of the object ? oCust.Company_Name ? oCust.Customer_Id * After editing, you can: GATHER NAME oCust |
See Also |