sx_CreateFrom

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_CreateFrom

VB Declaration

Declare Function sx_CreateFrom Lib "Apollo9.dll"

(ByVal cpFileName As String,

ByVal cpAlias As String,

ByVal cpStruFile As String,

ByVal iRDEType As Integer)

As Integer

C Declaration

SHORT FAR PASCAL sx_CreateFrom

(BYTEP cpFileName,

BYTEP cpAlias,

BYTEP cpStruFile,

SHORT iRDEType);

Description

Creates a new file from the structure extended file specified in the cpStruFile parameter.

Parameters

cpFileName: The name of the new table qualified with a complete path and extension.

cpAlias: The alias name to be assigned to the new file. Every database file opened must be assigned a unique alias name.

cpStruFile: The name of the structure extended file, including full path and extension if desired. The structure extended file may be created with sx_CopyStructureExtended or manually as long as it conforms to the following:

 

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

iRDEType: One of the following manifest constants:

 

 SDENTX 1 CA-Clipper compatible DBF-NTX driver

 SDEFOX 2 FoxPro compatible DBF-IDX/CDX driver

 SDENSX 3 Vista DBF-NSX driver

Return Value

True if successful or False if unsuccessful.

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 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_CopyStructureExtended, sx_CreateExec, sx_CreateField, sx_CreateNew