Command COPY STRUCTURE EXTENDED Foundation

Copies a list of field definitions to a new file.

Syntax
COPY STRUCTURE EXTENDED TO <cFilename>
Parameters
<cFilename>
<cFilename> specifies the name of the file to create to store the list of field definitions from the current work area. The name must contain the drive and path if they are necessary. It can be specified either as a literal file name or as a character expression in parentheses. If the file name is specified without extension, the default extension predetermined by the current database engine (DBE) is used. The default file extension for the DBFDBE is ".DBF".
Description

The command COPY STRUCTURE EXTENDED generates a structure extended file with four fields containing the field definitions of the fields in the current work area. For each field in the current work area, a data record is added to <cFilename>. The structure of the file <cFilename> is 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

The command COPY STRUCTURE EXTENDED is similar to the function DbStruct(), which returns the list of field specifications in a two-dimensional array. The command COPY STRUCTURE EXTENDED instead writes this information to a file. It is also used to define or change the field structure of database files at runtime of an Xbase++ application. The corresponding file can be created using the command CREATE FROM.

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 functional equivalent of COPY STRUCTURE EXTENDED is the function DbCopyExtStruct().

Examples
COPY STRUCTURE EXTENDED
// In the example, the file structure of a customer file 
// is modified using a structure extended file. A new 
// field is added for the fax number of a customer. 

PROCEDURE Main 

   USE Customer VIA "DBFNTX" NEW    // carry over structure 
   COPY STRUCTURE EXTENDED TO Struct 

   USE Struct                       // enter new 
   APPEND BLANK                     // field definition 

   REPLACE Field_Name WITH "FAXNO", ; 
           Field_Type WITH "C"    , ; 
           Field_Len  WITH 15     , ; 
           Field_Dec  WITH  0 
   USE 
                                    // save copy of 
   RENAME Customer.dbf TO Temp.dbf  //  - DBF file 
   RENAME Customer.dbt TO Temp.dbt  //  - Memo file 

   CREATE Customer FROM Struct      // create new file 
   USE Customer 

   APPEND FROM Temp                 // copy records 
                                    // from saved copy 
   CLOSE                            // rename saved files 
   RENAME Temp.dbf TO Customer.bak  //  - DBF file 
   RENAME Temp.dbt TO Customer.tbk  //  - Memo file 
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.