How to read and lock a record in code

Readlock is used to perform read operations on a table with an access key or temporary index, locking the record read.

 

Syntaxes

   Readlock [ class ] [ key ] read_mode [ value_key ]
   [ With lockwait = exp_times ]

 

# Read and lock loop for the first record in the
   # table [CLI] as long as it is not unlocked.
    Trbegin CLEINT [CLI]
    Repeat : Readlock [CLI]CLE First With lockwait = 1 : Until fstat = 0
    Commit

   # Attempt to read and lock a record from the
   # STK file until it is unlocked. CLE consists of
   # a numerical element and an alphanumerical element.
    Repeat Readlock [STK]CLE = [L]NUMPRO;[F:MAG]MAGAS Until fstat = 0
    # ... continuation of routine
    Unlock [STK]

   # Read and lock the last record in the sequence of the
   # key CLE2 (a date element, an alphanumeric element, an integer element),
   # for which there is a partial key less than the given values.
# The file read is the default file
    Readlock CLE2(2) < [29/05/2019]; "JJ"