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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question On RLOCK() 1

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
I'm looking at some inherited code at my jobsite here. If RLOCK() does the record locking, then does ? RLOCK()

1) only report back on whether or not the record is actually locked (.T. or .F.)?

2) actually place the lock and then report back that the record is locked?

Thanks
The 2nd mouse gets the cheese.
 
RLOCK() will return .T. if it could lock the record, and .F. if it couldn't. That's why you may see some code that looks like this:

IF !RLOCK()
MESSAGEBOX("Record in Use - Try again later",0,"Note")
RETURN
ENDIF
... Record Processing

Rick

 
Hi Rick,

Thanks for the clarification. But I have one small point...

Will the code

?RLOCK()

actually place the lock by on the record?

or does it just report on the lock status?

Thanks again.
The 2nd mouse gets the cheese.
 
rlock will lock the record - you may need to set mutilocks on if you are trying to lock multiple records
 
Yes, any variant of RLOCK() will lock it (IF it can):
xx = RLOCK()
= RLOCK()
IF RLOCK()
?RLOCK()
RLOCK()

Basically the RLOCK() function can't know how it's being called, so it's always going to respond the same way. I believe you're really asking if there is a way to check the "locked" status without using RLOCK(), and the answer is no.

Rick
 

Thanks my friend...
That settles the issue. :)
The 2nd mouse gets the cheese.
 
I realize this thread was awhile ago, but I have another answer for you. To check the lock status, use the following:

cLockStatus=sys(2011)

This will return a character string giving the current lock status of the record or table, such as "Record Locked", "Record Unlocked", "Exclusive", "File Locked", etc. The key point to this, of course, is that using this function does NOT actually try to lock the record. It simply tells you whether or not it is already.

Note that this will ONLY tell you whether or not YOU have it locked. If you run this command on a record that another user has locked, it will return "Record Unlocked". The only way to tell if someone else has it locked is to try to lock it yourself or try to make changes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top