HP 3000 Manuals

LOCK [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

LOCK 

The LOCK statement requests exclusive access to a file, for the program
that executes the lock statement.  If the file cannot be accessed at the
time the LOCK statement is executed, an option can be specified to delay
execution of the LOCK statement until the program has exclusive access.

Syntax 

LOCK #fnum [; WAIT num_var]

Parameters 

fnum             The file number that HP Business BASIC/XL uses to
                 identify the file.  It is a numeric expression that
                 evaluates to a positive short integer.

num_var          A numeric variable that contains a file locking flag.
                 Two conditions occur dependent on the value assigned to
                 num_var prior to the LOCK statement:

                  *  Zero:  File unlocking occurs unconditionally.  If
                     the file is being accessed by another program,
                     execution of the LOCK statement is suspended until
                     the file can be locked.

                  *  Non- Zero:  File locking occurs only if the file is
                     not currently locked.  If the file is locked,
                     program execution resumes without locking the file.

                 If the file is successfully locked, the value one is
                 assigned to num_var.  If the value of num_var prior to
                 the call is nonzero, then an unsuccessful attempt to
                 lock the file results in zero being assigned to num_var.

Examples 

     100 CREATE "File1",FILESIZE=1200  !Creates File1
     200 ASSIGN "File1" TO #10         !Assigns File1
     300 LOCK #10                      !Locks File1
     400 PRINT #10; A,B,C
     500 UNLOCK #10                    !Unlocks File1 after printing
     999 END



MPE/iX 5.0 Documentation