sdl_lock()

Locks or unlocks a library file

Call
#include <vv_des.h>
int sdl_lock(state, libp)

int state

State of lock for library (ON or OFF)

DLIBPTR libp Pointer to library to set locking for
Returns  
1 The library was locked or unlocked successfully.
0 Error. The global error code VV_ERR is set one of the following:
  ERROPEN The library file could not be opened
  DL_LOCKED The library file has already been locked.
Description

If the specified library is flagged as a read-only file or if library locking is not enabled, this function immediately returns a 1 to indicate success. It does not attempt to lock or unlock the library.

This function locks or unlocks the specified library, by creating a sub-directory with the name of the library and an extension. Under PCDOS, the sub-directory created is called libname.$$$.

Related Functions

se_dllocking()

Cautions

You must unlock and close all libraries before leaving your application. You can unlock a library in one of two ways: (1) by calling sdl_lock() to turn the lock off or (2) by closing the library with dl_close(). You can ensure that all libraries are closed and unlocked by calling vv_exit() just before returning in main() and in any of your abort functions.

In applications that run on a multi-user system, it is dangerous to leave libraries unlocked while forms are being read. Always lock the library when reading forms by either (1) allowing Vermont Views to lock and unlock the library automatically in dl_fmget() and dl_mnget() by enabling Designer library locking with se_dllocking(), or (2) calling sdl_lock() to lock the library yourself before reading a form or forms and then calling sdl_lock() again to unlock the library immediately afterwards.

Locking a library prohibits other programs, including copies of the same program in a multi-user system, from reading a form from the library. Always unlock the library as soon as possible, unless you are sure that the program will always be running in a single-user environment.

If se_dllocking() is set to OFF, sdl_lock() will not lock the library.


Home Contents Previous Next