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

UNLOCK a record in the reopen table

Status
Not open for further replies.

billyng

Programmer
Dec 7, 2004
25
US
Hi folks

If I do the following in the init()

SELECT table1
LOCATE for key=10
IF RLOCK()
&& do something
.....
USE IN table1
ENFIF

Can I just do

SELECT table1
UNLOCK IN table1

to release the record lock later in the destory()?

Thanks!
 
No, because you have already closed the table with your line...

use in table1

...but yes you have the general idea. You may want to look some of the commands up in the VFP help file to see what they do, they usually have some decent examples and instructions for their use (not always, but most of the time).

boyd.gif

 
Table1 might be open or closed when you get to Destroy because the USE IN Table1 will only close it if RLOCK succeeds.

Try something like this in Destroy:
Code:
If Used("Table1") Then
  Use in Table1
EndIf

By the way, what happens if the LOCATE fails to find key 10?

Geoff Franklin
 
Good point, I should use FOUND() to see if I can LOCATE. Thanks!

By the way, does it mean RLOCK() will be released after I close the table?

Thanks!

Billy Ng
 
billyng,

I think the VFP help file is pretty clear on this...

VFP Help said:
A table record can be unlocked only by the user who placed the lock. Record locks can be released by issuing UNLOCK, closing the table, or exiting Visual FoxPro.

I realize that you are trying to get your feet wet with VFP, and I'm all for that. VFP is a wonderful language and will serve you well in your endeavours. That having been said, not reading the help file/documentation available to you and instead using this Tek-Tips forum to garner answers that are so readily available is not really in the spirit of these forums.

Please don't take offense at what I am saying. These forums are for IT Professionals, and as such the members are held to a higher standard than you will find in most other forums. Based on this thread and others that you have started you could end up getting red flagged. If that happens, management will take a look at your threads and a determination could be made to delete your threads and/or terminate your membership. I've seen it happen many times.

So, in the future just take a good hard look at the help documentation for the command you are having an issue with and if it still has you stumped then post away and many members will be here to help you. In saying all of this I am trying to help, as I want you to stay around, increase in your proficiency with VFP, and some day help others with the new knowledge you've gained... that is after all what we are all doing here.

boyd.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top