Locking a file from update by all users

readlock

Lock a file from update by all users


SYNTAX

readlock file_id [riu = label] [traps = label]

The readlock command attempts to place a read lock on the file specified. A read lock prevents the file from being updated by any process, including the process that placed the lock.

The command enables records in a file to be examined with the certain knowledge that no records are currently being amended by other users.

A read lock is removed by means of the unlock command.

file_id

The identifier given to the file when it was declared (using ![o]file).

[riu = label]

Traps the condition where the read lock cannot be obtained due to an already existing locking condition.

It is not possible to obtain a read lock on a file if any record in it is currently locked, or if some other process has a write lock on the file. If readlock discovers that the file contains a locked record, a Record in use status occurs. This event may be trapped by use of the riu clause, or the traps clause, in which case control passes to the line indicated by label.

If this condition is not trapped, the message Waiting… is displayed, and the lock is retried every three seconds until successful.

[traps = label]

General purpose trap clause that traps any condition not explicitly trapped, passing control to the line indicated by label. It has the lowest priority, and is only invoked if a trappable condition has not been more explicitly trapped.


Platforms

Sculptor supports read locks on UNIX platforms and on Windows NT, 2000 and XP. Windows 95, 98 and ME do not support read locks, so all locks obtained locally on these platforms are write locks. However, a Sculptor client program that is running client/server on Windows 95, 98 or ME, and accessing files via kfserver on UNIX or Windows NT/2000/XP, has the benefit of both read locks and write locks, provided that the version of kfserver is 5.3 or later. The client version can be earlier. This is not the case if the program uses standard, Windows networking to access the files.


NOTES

  • On some systems more than one process can have a read lock on a file at the same time. Every locking process must unlock the file before it becomes available for update.

  • The related writelock command is used to lock a file from update by other users, while still permitting the current program to update it.


EXAMPLE

readlock File3 riu = F3LOCK

RELATED TOPICS

Sculptor keyed files

Servers

Traps

unlock

writelock