sx_CopyStructureExtended

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_CopyStructureExtended

VB Declaration

Declare Function sx_CopyStructure Lib "Apollo9.dll"

(ByVal cpFileName As String)

As Integer

C Declaration

SHORT FAR PASCAL sx_CopyStructure

(BYTEP cpFileName );

Description

Creates a table that holds the record structure of the currently selected file. The new structure extended file has the following format:

 

FIELD NAME TYPE LEN DEC

FIELD_NAME C 10 0

FIELD_TYPE C 1 0

FIELD_LEN N 5 0

FIELD_DEC N 3 0

 

Each record in the output file represents one field in the source table. This function, in conjunction with sx_CreateFrom, may be used to create empty copies of a given table. The structure extended file may also be modified by adding, deleting, or changing items such as field length - which allows modification of the source file.

Parameters

cpFileName: The name of the table that will hold the structure of the currently selected file. Full path and extension may be included.

Return Value

True or False depending on the outcome of the operation.

Note: Field types should not be changed. If a field type is changed from character to numeric, for example, sx_AppendFrom will not copy the contents of the old character field to the new numeric field.

VB Example

The pseudo code below shows the steps required to modify an existing table (SOURCE.DBF):

sx_Use("c:\data\source.dbf", "source", EXCLUSIVE, SDEFOX)

sx_CopyStructureExtended( "c:\data\struc.dbf" )

sx_Close

sx_Use("c:\data\struct.dbf", "struct", EXCLUSIVE, SDEFOX)

MODIFY FIELD DESCRIPTOR RECORDS

DELETE FIELD DESCRIPTOR RECORDS

ADD FIELD DESCRIPTOR RECORDS

sx_Pack ' If field descriptors deleted

sx_Close

sx_CreateFrom( "c:\data\newdbf", "new", "c:\data\struct", SDEFOX )

sx_AppendFrom( "c:\data\source", SDEFOX, 0& )

Kill "c:\data\struct.dbf"

C C Example

The pseudo code below shows the steps required to modify an existing table (SOURCE.DBF):

 

sx_Use("c:\\data\\source.dbf", "source", EXCLUSIVE, SDEFOX);

sx_CopyStructureExtended( "c:\\data\\struc.dbf" );

sx_Close();

sx_Use("c:\\data\\struct.dbf", "struct", EXCLUSIVE, SDEFOX);

MODIFY FIELD DESCRIPTOR RECORDS

DELETE FIELD DESCRIPTOR RECORDS

ADD FIELD DESCRIPTOR RECORDS

sx_Pack(); // If field descriptors deleted

sx_Close();

sx_CreateFrom( "c:\\data\\newdbf", "new", "c:\\data\\struct", SDEFOX );

sx_AppendFrom( "c:\\data\\source", SDEFOX, NULL );

Unlink( "c:\\data\\struct.dbf" );

See Also

sx_AppendFrom, sx_CopyStructure, sx_CreateExec, sx_CreateField, sx_CreateFrom, sx_CreateNew