sx_CopyStructure

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_CopyStructure

VB Declaration

Declare Function sx_CopyStructure Lib "Apollo9.dll"

(ByVal cpFileName As String,

ByVal cpAlias As String)

As Integer

C Declaration

BOOL FAR PASCAL sx_CopyStructure

(BYTEP cpFileName,

BYTEP cpAlias);

Description

Creates a table that has the same structure as the current table. The new file is created and then closed.

Parameters

cpFileName: The DOS name of the target file 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.

Return Value

True or False depending upon the outcome of the operation.

VB Example

' make a batch file in the image of the master

MArea = sx_Use("\vb\trans.dbf", "trans", READWRITE, SDENTX)

If sx_CopyStructure("c:\vb\batch.dbf", "batch") Then

sx_Close

BatchArea = sx_Use("\vb\batch.dbf", "batch", READWRITE, SDENTX)

Call CaptureTransactions

If sx_RecCount() > 0 Then

sx_Close

MArea = sx_Use("\vb\trans.dbf", "trans", READWRITE, SDENTX)

If sx_AppendFrom("c:\vb\test\batch.dbf", SDENTX, 0&) Then

MsgBox "appended transactions successfully"

Else

MsgBox "appendfrom failed"

End If

Else

MsgBox "Copy structure failed"

End If

C Example

void CNamesForm::OnButtonOpenBatch()

{

sx_Use("c:\\work\\trans.dbf", "trans", READONLY, SDENTX);

if (sx_CopyStructure("c:\\work\\batch.dbf", "batch"))

{

sx_Close();

sx_Use("c:\\work\\batch.dbf", "batch", READWRITE, SDENTX);

CaptureTransactions();

if (sx_RecCount() > 0)

{

sx_Close();

sx_Use("c:\\work\\trans.dbf", "trans", READWRITE, SDENTX);

if (sx_AppendFrom("c:\\work\\batch.dbf", SDENTX, NULL))

AfxMessageBox((LPCSTR) "Batch append succeeded.");

else

AfxMessageBox((LPCSTR) "Batch append failed.");

}

}

else

AfxMessageBox((LPCSTR) "Copy structure failed.");

}

See Also

sx_CopyStructureExtended, sx_AppendFrom, sx_CopyFile, sx_CreateExec, sx_CreateField, sx_CreateNew