Command CREATE Foundation

Creates and opens an empty structure extended DBF file.

Syntax
CREATE <cFilename>
Parameters
<cFilename>
<cFilename> specifies the name of the file to create. The name must contain the drive and path if they are necessary. <cFilename> can be specified either as a literal file name or as a character expression in parentheses. When the file name is specified without a file extension, the default extension predetermined by the current database engine (DBE) is used. The default file extension of the DBFDBE is ".DBF".
Description

The file command CREATE creates an empty structure extended file with the name <cFilename> and opens it in the current work area. A structure extended file contains in its records the field definitions for another file. The fields of a structure extended file are shown in the following table:

Structure of an extended file
Field name Field type Field length Decimal places
FIELD_NAME Character 10 0
FIELD_TYPE Character 1 0
FIELD_LEN Numeric 5 0
FIELD_DEC Numeric 4 0

New databases can be created from the records of a structure extended file. This is done using the command CREATE FROM. Databases can also be created using the function DbCreate(). This function uses a two dimensional array instead of a file for information on the field definitions.

Contrary to dBase or Clipper, the length of the field FIELD_LEN is not 3 but 5. The length of a character field with more than 999 characters can be entered directly and no longer needs to be encoded using the decimal places FIELD_DEC.

The function CreateExtStruct() is the functional equivalent of the command CREATE.

Examples
CREATE
// The example demonstrates how files can be created 
// using CREATE and CREATE FROM. 

PROCEDURE Main 

   CREATE Struct 
   APPEND BLANK 

   REPLACE FIELD_NAME WITH "UserID" , ; 
           FIELD_TYPE WITH "C" , ; 
           FIELD_LEN  WITH  5  , ; 
           FIELD_DEC  WITH  0 

   APPEND BLANK 
   REPLACE FIELD_NAME WITH "UserName" , ; 
           FIELD_TYPE WITH "C" , ; 
           FIELD_LEN  WITH  30 , ; 
           FIELD_DEC  WITH  0 

   CLOSE 

   CREATE Login FROM Struct 

   ERASE Struct.dbf 
RETURN 
Feedback

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.