Adds to the current table one or more records containing data stored in a specified array.

Syntax

APPEND FROM ARRAY <array>
[FIELDS <field list>]
[FOR <condition>]
[REINDEX]

<array>

A reference to the array containing the data to store in the current table as records.

FIELDS <field list>

Appends <array> data only to the fields in <field list>. Without FIELDS <field list>, APPEND FROM ARRAY appends to all the fields in the table, starting with the first field.

FOR <condition>

Restricts APPEND FROM ARRAY to array rows in <array> that meet <condition>. The FOR <condition> should reference the fields in the current table. dBASE Plus pretends that the record is appended, then evaluates the <condition>. If it fails, the record is not actually appended.

REINDEX

Rebuilds open indexes after all records have been changed. Without REINDEX, dBASE Plus updates all open indexes after appending each record from <array>. When the current table has multiple open indexes or contains many records, APPEND FROM ARRAY executes faster with the REINDEX option.

Description

APPEND FROM ARRAY treats one- and two-dimensional arrays as tables, with columns corresponding to fields and rows corresponding to records. A one-dimensional array works as a table with only one row; therefore, you can append only one record from a one-dimensional array. A two-dimensional array works as a table with multiple rows; therefore, you can append as many records from a two-dimensional array as it has rows.

When you append data from an array to the current table, dBASE Plus appends each array row as a single record. If the table has more fields than the array has columns, the excess fields are left empty. If the array has more columns than the table has fields, the excess columns are ignored. The data in the first column is added to the first field's contents, the data in the second column to the second field's contents, and so on.

The data types of the array must match those of corresponding fields in the table you are appending. If the data type of an array element and a corresponding field don't match, dBASE Plus returns an error.

If the current table has a memo field, dBASE Plus ignores this field. For example, if the second field is a memo field, dBASE Plus adds the data in the array's first column to the first field's contents, and the data in the array's second column to the third field's contents.

Use APPEND FROM ARRAY as an alternative to automem variables when you need to transfer data between tables where the structures are similar but the field names are different.

OODML

Use two nested loops to first call the Rowset object’s beginAppend( ) method to create the new rows, and then to copy the elements of the array into the value properties of the Field objects in the rowset’s fields array.