Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- RLIB 3.0a Reference - <b>function:</b> dbfcreate() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function:    DBFCREATE()

Purpose:     Dynamically create a database from a structure array.

Syntax:      DBFCREATE( filename, structure [, appendfile ] )

Arguments:   filename    - Character filename to create.  This must be a
                           valid DOS filename and may be fully qualified
                           (i.e.  have a full path specification).  If no
                           path specification is provided as part of the
                           filename, the file is created in the current
                           default directory.

             structure   - An array containing the structure definition
                           for the .DBF file to be created.  This is an
                           array of character strings with each element
                           defining the structure of each field.  See the
                           tables below for examples.

             appendfile  - Optional character filename of the .DBF format
                           file to append into the newly DBFCREATED file.
                           This filename may be fully qualified and, if
                           not, the file must exist in the current default
                           directory.

Returns:     True if the file was successfully created, false otherwise.

Description: DBFCREATE() is a database function that creates a database
             file from a structure array.  If an append file is specified,
             it is appended into the newly created database file.  The
             format of the character structure array is as follows:

             ELEMENT     FIELD NAME TYPE  LENGTH  DECIMALS
             array[1] = "NAME         C     30         "
             array[2] = "BIRTHDATE    D      8         "
             array[3] = "AGE          N      2        0"
             array[4] = "MALE         L      1         "
             array[5] = "NOTES        M     10         "

             This structure is not rigid.  The number of spaces between
             the field name, field type, length and decimals may vary.
             The only rules are: space for field names must be at least 10
             spaces; field type - 1 space, field length - 4 spaces, and 4
             spaces for field decimals.  If the field type is character,
             no field decimal need be specified.

Notes:       Although the Clipper manual does not state that the CREATE,
             CREATE FROM, or APPEND FROM commands require the target file
             to be FLOCK()ed or USEd EXCLUSIVEly, in a Network
             environment, for safety sake, and for data integrity sake,
             you may wish to SET EXCLUSIVE ON before calling this
             function.  Although you may not experience any problems by
             not doing so, common data design sense should dictate
             otherwise.

Example:     *-- create a database named TEST.DBF, and append existing
             *-- old data in from TEST.BAK
             DECLARE struc[5]
             struc[1] = "NAME         C     20    0"
             struc[2] = "ADDRESS      C     30    0"
             struc[3] = "CITY         C     20    0"
             struc[4] = "STATE        C      2    0"
             struc[5] = "ZIP          C      5    0"
             DBFCREATE( "TEST.DBF", struc, "TEST.BAK" )

Source:      RL_DBFCR.PRG

See also:    CLOSEAREA(), OPENED()

See Also: CLOSEAREA() OPENED()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson