Sample Locking

 

<< Click to Display Table of Contents >>

Navigation:  Samples >

 

Sample Locking

 

Previous pageReturn to chapter overviewNext page

 

Purpose

 

 

Locking sample

 

 

 

Description

 

 

This sample shows how you can use Client ID's to influence the locking

 

 

 

 

Example(s)

 

 

FUNCTION Start

LOCAL oSrv1 AS BtDDFServer

LOCAL oSrv2 AS BtDDFServer

LOCAL oSrv3 AS BtDDFServer

LOCAL cDir                AS STRING

// if you run this sample twice only the first sample will be able to lock

// the files.

? Bt_GetClientName()

Bt_SetClientName("CA")

? Bt_GetClientName()

// Set global client id to 1

Bt_SetClientId(1)

// Next files will be opened under client #1, because no client id

// is specified

cDir := "D:"

oSrv1 := btDDFServercDir,"Student",cDir,BFM_NORMAL

oSrv2 := btDDFServercDir,"Student",cDir,BFM_NORMAL

// Next file will be opened under client #2, because of the explicit ID

// Now locking of files is handled as if they are seperate workstations

oSrv3:= btDDFServercDir,"Student",cDir,BFM_NORMAL,,2

oSrv1:GoTop()

oSrv2:GoTop()

oSrv3:GoTop()

// Now you will see 2 Clients RH on the novell monitor:

// Client 1 has the file opened twice

// Client 2 has the file opened once

? "Clientid Server 1", oSrv1:ClientId

? "Clientid Server 2", oSrv2:ClientId

? "Clientid Server 3", oSrv3:ClientId

? oSrv1:RLock()                                                                // True

? oSrv2:RLock()                                                                // True, same Client ID as oSrv1

? oSrv3:RLock()                                                                // False, different Client Id

wait

oSrv1:Close()

oSrv2:Close()                

oSrv3:Close()