lock

lock(lockTarget:   Object;
     lockType:     Integer;
     lockDuration: Integer;
     timeout:      Integer);

The lock method of the Object class acquires the type of lock specified in the lockType parameter for the object specified in the lockTarget parameter.

The duration and time of the lock are specified by the lockDuration and timeout parameters, respectively. (The timeout parameter specifies the number of milliseconds for the timeout.)

The following table lists the lock type, lock duration, and timeout global constant values.

Global Constant Integer Value Category
Exclusive_Lock 3 Locks
Reserve_Lock 2 Locks
Share_Lock 1 Locks
Update_Lock 4 Locks
Persistent_Duration 2 LockDurations
Session_Duration 1 LockDurations
Transaction_Duration 0 LockDurations
LockTimeout_Immediate -1 LockTimeouts
LockTimeout_Infinite Max_Integer (#7FFFFFFF) LockTimeouts
LockTimeout_Process_Defined -2 (use the process‑defined default) LockTimeouts
LockTimeout_Server_Defined 0 (use the server-defined default) LockTimeouts

The following example shows the use of the lock method.

createMe(newname, newadd1, newadd2, newadd3: String; newcash: Decimal)
         updating;
begin
    exclusiveLock(self);
    on LockException do alreadyInUse(exception);
    lock(self, Exclusive_Lock, Transaction_Duration, 100);
    self.name     := newname;
    self.address1 := newadd1;
    self.address2 := newadd2;
    self.address3 := newadd3;
    if newcash = 0 then
        self.cash := 100000;
    else
        self.cash := newcash;
    endif;
    self.myMarket := app.myMarket;
end;