[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|        APPEND FROM ARRAY        |
+---------------------------------+
APPEND FROM ARRAY <array>
        [FOR <expL>]
        [FIELDS <field list>]

-----------------------------------
Adds records to a database from an array.  Locks database header in
FoxPro/LAN.
-----------------------------------

<array>
        Name of array.

FOR <expL>
        Conditionally appends records from array.

FIELDS <field list>
        Specifies fields to be updated from array.  Memo fields are ignored in
APPEND FROM ARRAY.

One-Dimensional Arrays

The table below shows default values fields are initialized to if
database has more fields than array has elements.

Field Type              Default Value
-----------------------------------

Character               Spaces
Numeric                 0
Date                    Blank
Logical                 False (.F.)

Two-dimensional Arrays

The table below illustrates whether replacement occurs when there is a
data type mismatch.

Element Type    C       N       D       L
-----------------------------------
Character               X
Numeric                 X       X               X
Date                    X       X       X
Logical                 X                       X

+---------------------------------+
|             Example             |
+---------------------------------+
This example illustrates how you can add a record to a database.
CUSTOMER database is opened and SCATTER creates array named CUSTARRAY
with blank element for each field in database.  A FOR ... ENDFOR loop
displays each field.  READ command activates GETs.

If Escape isn't pressed to exit editing, APPEND FROM ARRAY appends a new
record to database.  Data in CUSTARRAY memory variable array then
replaces each field.

CLOSE ALL
SET TALK OFF
CLEAR
SELECT 0
USE customer
SCATTER TO custarray BLANK       && Create an blank array

FOR count = 1 TO ALEN(custarray) && Number of rows in array
        @ count, 2 SAY FIELD(count) ;
                GET custarray(count)         && Display fields and get info
ENDFOR

READ

IF READKEY() != 12             &&  If Escape isn't pressed
        APPEND FROM ARRAY custarray    && Append a record, fill from array
ENDIF
USE
CLEAR

-----------------------------------

See Also:  COPY TO ARRAY, DECLARE, DIMENSION, GATHER, SCATTER, STORE

-----------------------------------

See Also: COPY TO ARRAY DECLARE DIMENSION GATHER SCATTER STORE
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson