sx_Flock

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_Flock

VB Declaration

Declare Function sx_Flock Lib "Apollo9.dll" () As Integer

C Declaration

BOOL FAR PASCAL sx_Flock (VOID);

Description

Locks the current table.

Return Value

True if the lock was successful and False if not. In Windows, SHARE.EXE should be loaded at the work station in order to achieve consistent file lock results.

Locks will be retried according to the time-out value set via sx_SetLockTimeout before returning a lock failure.

VB Example

' reindex

iArea = sx_Use("\vb\sxlog.dbf", "sxlog", READWRITE, SDENTX)

Log1Ntx = sx_IndexOpen("C:\vb\sxlog1.ntx")

Log2Ntx = sx_IndexOpen("C:\vb\sxlog2.ntx")

 

If sx_Flock() Then

sx_SetGaugeHook GaugeBox.hWnd

GaugeFiles = 2 ' global to set gauge proportion

sx_Reindex

sx_SetGaugeHook 0

sx_Unlock 0

Else

MsgBox "Lock failed. Try again later."

End If

C Example

void CNamesForm::OnButtonAppendBatch()

{

// save master before append

if (sx_Flock())

{

sx_CopyFile("c:\\back\\sqmback.dbf");

if (!sx_AppendFrom("c:\\vb\\sxqueue.dbf", SDENTX, NULL))

{

// on failure, restore master

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

sx_Close();

sx_Use("c:\\back\\sqmback.dbf", "qback", READONLY, SDENTX);

sx_CopyFile("c:\\vb\\SDE2\\sqmast.dbf");

sx_Use("c:\\vb\\sqmast.dbf", "qmaster", READWRITE, SDENTX);

}

else

{

sx_GoTop();

sx_Unlock(0);

}

}

else

AfxMessageBox((LPCSTR) "File lock failed.");

}

See Also

sx_Locked, sx_Rlock, sx_SetLockTimeout, sx_Unlock