Commands and Statements

Command SCATTER NAME Foundation

Copies data from the current record to a DataObject.

SCATTER [FIELDS <FieldNameList] NAME <oData>  [IN <nWorkArea>|<cAlias>] [ADDITIVE]
SCATTER FIELDS EXCEPT <SkeletonList> NAME <oData>  [IN <nWorkArea>|<cAlias>] [ADDITIVE]
SCATTER FIELDS LIKE <SkeletonList> [EXCEPT <SkeletonList>] NAME <oData>  [IN <nWorkArea>|<cAlias>] [ADDITIVE]
A comma-separated list of field names. If no fields are specified, all fields in the current record are selected.
The work area to copy the data from. <nWorkArea> is a positive integer with the ordinal number of the work area. <cAlias> is the alias name of the work area specified either as a literal string or as a character expression in parentheses. If no work area is specified, the current work area is selected.
A list of field names specified as string literals to be included or excluded in the operation. The list can include both qualified field names as well as wildcard patterns. See Like() for supported wildcard patterns.
The variable with the DataObject the data is copied to.
If this option is used, the data is copied to the existing data object passed in <oData>. By default, a new data object is created instead and assigned to the variable.

The command SCATTER NAME copies data from the current record of a work area to a data object. By default, SCATTER NAME first creates a new DataObject, and then adds an exported member variable for each field selected via the FIELDS, FIELDS EXCEPT or FIELDS LIKE argument. If no fields are specified, all fields in the current record are copied.

The ADDITIVE option can be used to copy the data to an existing data object. In this case, the value in each field is copied to the corresponding member variable of the data object. If none exists, a new member variable is added. Other member variables of the data object are left unchanged. If ADDITIVE is not used or if no data object is specified in the <oData> argument, a new DataObject is created by SCATTER NAME which only has the data from the fields specified to the command.

Example for SCATTER NAME usage
/// - opens a dbf table and loads record #5 into a DataObject 
/// - closes table and shows data stored in DataObject 
LOCAL oCustomer 

USE customer 
GO 5 

? FCount()            // 13 

? oCustomer:lastname  // Hellstrom 
? oCustomer:custNo    // 5 
? Len( oCustomer )    // 13 

SCATTER FIELDS lastname, firstname NAME oCustomer 
? oCustomer:lastname        // Hellstrom 
? oCustomer:custNo          // NIL (undefined/not copied) 

SCATTER FIELDS EXCEPT "notes", "*name" NAME oCustomer 
? oCustomer:lastname        // NIL (undefined/not copied) 
? oCustomer:custNo          // 5 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.