DbCopyXStruct Function | |
Copy the field definitions in a database file structure to a structure-extended file as data.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION DbCopyXStruct(
cTargetFile AS STRING
) AS LOGIC
public static bool DbCopyXStruct(
string cTargetFile
)
Request Example
View SourceParameters
- cTargetFile
- Type: String
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 cTargetFile does not exist, it is created.
If it exists, this function 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.
DBCreate() creates the specified file in ANSI or OEM character set format, based on the SetAnsi() setting. (For more information, refer to the SetAnsi() function.)
Return Value
Type:
Logic
TRUE if successful; otherwise, FALSE.
Remarks
DBCopyXStruct() creates a database file whose contents is the structure of the current database file, with a record for the definition of each field.
By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying
it within an aliased expression
The structure-extended database file has the following structure:
Name Type Length Decimals
Field_Name Character 10
Field_Type Character 1
Field_Len Numeric 3 0
Field_Dec Numeric 3 0
Used in application programs, DBCopyXStruct() 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.
DBCopyXStruct() is the functional implementation of the COPY STRUCTURE EXTENDED command.
Tip |
---|
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 DBCopyXStruct(), you can use the following formula to determine the length of any character field:
1nFieldLen := If((Field_Type = "C" .AND. ;
2 Field_Dec != 0), Field_Dec * 256 + ;
3 Field_Len, Field_Len) |
Examples
The following example creates a new structure-extended file:
1USE test
2IF Used()
3 DBCopyXStruct("stru.dbf")
4ENDIF
See Also