Using KSAM/XL and KSAM 64 (32650-90886)

238 AppendixB
BASIC/V Intrinsics
BKLOCK
BKLOCK
Dynamically locks KSAM file during shared access.
CALL BKLOCK(
filenum,status
[
,condition
])
When more than one user accesses the same file, BKLOCK can be used to make access to the
file exclusive for one user while he writes to or updates the file. In order to use BKLOCK, the
file must be opened with dynamic locking allowed by all users who are sharing the file.
When finished with the changes that required exclusive access, the user who has locked
the file with BKLOCK should unlock it with BKUNLOCK.
NOTE
Note that a file opened for shared access must be locked by BKLOCK before the
file can be modified by BKWRITE, BKREWRITE, or BKDELETE.
Parameters
filenum
A numeric variable containing the file number that identifies the file; this
number was returned to
filenum
by the last call to BKOPEN. It should not
be altered unless the file is successfully closed by BKCLOSE. (
Required
parameter
)
status
A four-character string variable to which is returned a code that indicates
whether or not the call to BKLOCK was successful and if not, why not. The
first character is set to zero when the call succeeds, to another value if it
fails. (
Required parameter
)
condition
A numeric expression whose value determines the action taken if the file is
locked by another user when BKLOCK is executed. If the value of
condition
is:
Zero-locking is unconditional.
If the file cannot be locked immediately because another user has
locked it, your program suspends execution until the file can be locked.
(
default value
)
Non-zero-locking is conditional.
If the file is already locked, control returns immediately to your
program with
status
set to 71.
(
Optional parameter
)
Default: If omitted, locking is
unconditional
.
Operation Notes
In order to call BKLOCK, the file must be opened with dynamic locking allowed. That is, the
parameter
lock
in the BKOPEN procedure must be set to 1. Also, since dynamic locking is
useful only when access is shared, probably the file will have been opened with the
exclusive
parameter in BKOPEN set to 3.