Show/Hide Toolbars

XSharp

NoteThis command is defined in a header file and will be preprocessed by the X# preprocessor to a function call. If you disable the standard header (-nostddefs) files then this command will not be available. If you tell the compiler to use a different standard header file (-stddef ) then this command may also be not available

Purpose

Copy the field definitions in a database file structure to a structure-extended file as data.

Syntax

COPY STRUCTURE EXTENDED TO <xcTargetFile>

Arguments

TO <xcTargetFile>The name of the target structure-extended database file, including an optional drive, directory, and extension. See SetDefault() and SetPath() for file searching and creation rules.  The default extension for database files is determined by the RDD .
 
If <xcTargetFile> does not exist, it is created.  If it exists, this command attempts to open the file in exclusive mode and, if successful, the file is overwritten without warning or error.  If access is denied because, for example, another process is using the file, NetErr() is set to TRUE.  

Description

COPY STRUCTURE EXTENDED creates a database file whose contents is the structure of the current database file, with a record for the definition of each field.  

The structure-extended database file has the following structure:

 

Field NameType        Length        Decimals        
Field_NameCharacter        10                
Field_TypeCharacter        1                
Field_LenNumeric        3                0
Field_DecNumeric        3                0

 

Used in application programs, COPY STRUCTURE EXTENDED permits you to create or modify the structure of a database file programmatically.  To create a new database file from the structure-extended file, use CREATE FROM.  If you need an empty structure-extended file, use CREATE.

Notes

Character field lengths greater than 255: Field lengths greater than 255 are represented as a combination of the Field_Dec and Field_Len fields.  After performing COPY STRUCTURE EXTENDED, you can use the following formula to determine the length of any character field:

 

nFieldLen := IIf((Field_Type = "C" .AND. ;
         Field_Dec != 0), Field_Dec * 256 + ;
         Field_Len, Field_Len)

Examples

This example creates STRUC.DBF from SALES.DBF as a structure-extended file, then lists the contents of STRUC.DBF to illustrate the typical layout of field definitions:

 

USE sales NEW
COPY STRUCTURE EXTENDED TO struc
USE struc NEW
LIST Field_Name, Field_Type, Field_Len, Field_Dec
 
 
// Result:
1 BRANCH                        C                3                0
2 SALESMAN                        C                4                0
3 CUSTOMER                        C                4                0
4 PRODUCT                        C                25                0
5 AMOUNT                        N                8                2
6 NOTES                        C                0                125
// Field length is 32,000 characters

Assembly

XSharp.RT.DLL

See Also

COPY STRUCTURE, CREATE, CREATE FROM, FieldName(), DbCopyXStruct(), SetDefault(), SetPath(), Type()