Microsoft KB Archive/93349

= Microsoft Knowledge Base =

Using SCATTER and GATHER in FoxBASE+
Last reviewed: March 28, 1995

Article ID: Q93349

The information in this article applies to:


 * Microsoft FoxBASE+ for MS-DOS, versions 1.02, 2.0, 2.1, 2.5x, 2.6, and 3.0

SUMMARY
The SCATTER command moves data from the current database record into an array of memory variables. The SCATTER command transfers the fields of the record into sequential elements of the array. If it is present, the FIELDS clause specifies the fields to transfer. Otherwise, the SCATTER command copies all fields.

The GATHER command moves date from an array of memory variables into the current record in the active database. The GATHER command transfers the elements of the array, beginning with element 1, into the corresponding fields of the database record.

MORE INFORMATION
If the array has more elements than the number of fields specified in the SCATTER statement, subsequent elements remain unchanged. If the array does not exist, or if the array is not large enough to hold the specified fields, the SCATTER command creates a new array of the required size. The SCATTER command sets the data type of each array element to be the same as that of the corresponding field in the database.

If the array has fewer elements than the number of fields in the database record, the GATHER command does not change subsequent elements. If the array has more elements than the number of fields in the database record, the GATHER command ignores subsequent array elements. If the data type of an array element does not match that of a corresponding database record, a &quot;Data type mismatch&quot; (error #9) occurs.

Memo fields are ignored by the SCATTER and GATHER commands.

Example:

SCATTER TO temp  && scatters contents of current && record into an array named temp GATHER FROM temp && gathers contents from an array && named temp into the current record