Log In    |    Knowledge Base    |    4D Home
Tech Tip: Developing with a Locked Structure (read only file, limited write permissions)
PRODUCT: 4D Server | VERSION: 2003 | PLATFORM: Mac & Win
Published On: June 3, 2004

4D or 4D Server can open a database from a CD. In this case 4D will be working with a structure file that is locked. Though this may be a useful feature, there can be other cases that also work with a structure that is locked (for instance, when you copy the structure from a CD to the hard disc and forget to unlock the structure). If you now develop with this structure in client/server mode, changes you make with 4D Client are written in the cache and are lost when quitting 4D Server.

Here's how to work around this:
To make changes in the password system, the structure or the password system itself must not be locked. If it is locked, you get an error -9937, which states that the password system is locked by another user. So, in the On Startup you start a new process with a test procedure:

<>ref:=New process("MyLockProc";32*1024)

The test procedure tries to change the user properties by itself:

ON ERR CALL("FaultProc")
DELAY PROCESS(Current Process;60)
GET USER PROPERTIES(2;name;startup;pass;uses;dat)
$error:=Set user properties(2;name;startup;pass;uses;dat)

If the structure is locked, the kernel generates error -9937, and your error handler starts. Here you can open an Alert to inform the developer, etc.

IMPORTANT: The test procedure MUST be started in a new process. the delay MUST not be shorter than 60 ticks.