Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RLock() is not working

Status
Not open for further replies.

wrov

Programmer
Nov 1, 2002
43
PY
Hello everybody

I'm having a problem on a net. Records seems not be locked.

Computer #1
-----------
USE \\NANCY\C\SISTEMAS\USUARIOS SHARED
=RLOCK()
BROWSE FOR ISRLOCKED()

The first record is showed. That's ok.

Computer #2 (a few seconds later)
-----------
USE \\NANCY\C\SISTEMAS\USUARIOS SHARED
BROWSE FOR ISRLOCKED()

The browse is empty. Nothing is showed there.

SET STATUS ON
GO TOP

On the status bar I can see:
Record Unlocked | Rec: 1/5

I was expecting to see the first record locked, but it's not. Somebody can explain me what happen here ?

Thanks in advance.

Walter.


P.S.:
-----
O.S. = Windows 98
USUARIOS.DBF = 5 records, no index
 
The helpfile regarding isrlocked() says:

"ISRLOCKED( ) returns a logical true (.T.) if the record is locked by the current application; otherwise a logical false (.F.) is returned.

Note ISRLOCKED() only returns .T. at the workstation that applied the record lock."

So, the second computer will never return a .T. with this function because it has no lock on the locked record by computer 1.

Rob.

 
Thanks a lot Rob

But the help file of the Visual FoxPro 6.0 in Spanish say:

ISRLOCKED( ) devuelve un valor lógico verdadero (.T.) si el registro está bloqueado; de lo contrario devuelve un valor lógico falso (.F.).

that means: ISRLOCKED() return .T. if the record is blocked else it return .F.

How you can see, it's not the same thing. Nothing there about current application or workstation.

Good luck.

Walter.
 
This is the vfp6 english text.
The text talks about having a rlock() in a specific workarea.
From an app you can only test your OWN rlock() and not rlock() by another application.
I agree that the VFP8 helpfile is more clear on the subject.

Rob.

The helptext:

ISRLOCKED( ) Function
See Also

Returns the record lock status.

Syntax

ISRLOCKED([nRecordNumber, [nWorkArea | cTableAlias]])

Returns

Logical

Arguments

nRecordNumber

Specifies the number of the record for which the lock status is returned. If nRecordNumber is omitted, the record lock status is returned for the current record.

nWorkArea

Specifies the work area number of the table for which the record lock status is returned. If you omit cTableAlias and nWorkArea, the record lock status is returned for the table open in the current work area.

cTableAlias

Specifies the alias of the table for which the record lock status is returned.

Remarks

ISRLOCKED( ) returns a logical true (.T.) if the record is locked; otherwise a logical false (.F.) is returned.
 
If you add a field to the table named LockedBy and you add the username to that field when someone locks a record then you can allways read who has a current lock on the record when you cannot lock the record or if isrlocked() returns .f.
When this user unlocks be sure to clear the LockedBy field.

Rob.
 
Thanks Rob

Having a field named LockedBy can work on normal circunstances but if the user press the Reset button then the field can return a not correct value.

Any way, I can resolve it. There are others way to do. It is a pity than IsRLocked() not work in the expected fashion.

Good luck.

Walter.
 
You can always write your own ....

function my_isrlocked()
local isLocked
isLocked = not rlock()
unlock
return isLocked


Don


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top