Groups > dBase > dBase support > Re: Proper Retrieval of Locking information




Proper Retrieval of Locking information

Proper Retrieval of Locking information
Fri, 30 Nov 2007 15:10:50 -050
Hello,

We currently are running legacy code written in dBASE for MS-DOS. In our
program, if a file is locked it keeps people from performing tasks until it is
unlocked. What we would like to do is gather the information on who locked it,
etc.

I have run the CONVERT [TO 24] command to make room for to store the information
on our databases. But when using LKSYS() I only get information from LKSYS(3),
LKSYS(4), and LKSYS(5) when I run [? LKSYS(4)] from the command window after
locking a file.

So far, I am unable to use the commands successfully in a program to return any
information. The test scenario has a different PC locking the file and another
PC trying to read from it. So far it just generates an error which calls our
error routine. Our error routine only gives the 108 message.

Is there a way to try to read a file and then use the LKSYS() to return the
information if I is locked?

Currently I try to lock the the file again. When I get .F. result from the try,
I have it display an error message with the LKSYS(3) but it will not show the
information.

Any help is GREATLY appreciated.
Thanks,
Post Reply
Re: Proper Retrieval of Locking information
Sat, 1 Dec 2007 00:52:57 -0500
In article <EJZka04MIHA.1084@news-server>, mrockhold@walzeq.com says...
> Hello,
> 
> We currently are running legacy code written in dBASE for MS-DOS. In our
program, if a file is locked it keeps people from performing tasks until it is
unlocked. What we would like to do is gather the information on who locked 
it, etc.
> 
> I have run the CONVERT [TO 24] command to make room for to store the
information on our databases. But when using LKSYS() I only get information from
LKSYS(3), LKSYS(4), and LKSYS(5) when I run [? LKSYS(4)] from the command 
window after locking a file.
> 
> So far, I am unable to use the commands successfully in a program to return
any information. The test scenario has a different PC locking the file and
another PC trying to read from it. So far it just generates an error which 
calls our error routine. Our error routine only gives the 108 message.
> 
> Is there a way to try to read a file and then use the LKSYS() to return the
information if I is locked?
> 
> Currently I try to lock the the file again. When I get .F. result from the
try, I have it display an error message with the LKSYS(3) but it will not show
the information.
> 
> Any help is GREATLY appreciated.
> Thanks,
> Matthew
> 

Matthew,

From the on-line help:

When a file is locked, this same information is stored in the _DBASELOCK 
field of the first physical record in the table.

Are you at the first record of the table when you check?

Which version of dBASE are you using? Which version of Windows is this? 
What type of networking?

Can you show us a sample of your code that you are using for attempting 
to lock the table and for using LKSYS()?

-- 
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.|        dBASE info at http://geocities.com/geoff_wass       |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
Post Reply
Re: Proper Retrieval of Locking information
Mon, 03 Dec 2007 07:49:05 -080
Matthew wrote:
> If FLOCK () == .F.
>  ? "File Locked on " + LKSYS(0) + LKSYS(1) + LKSYS(2) + LKSYS(3)
+ LKSYS(4) + LKSYS(5)
>  WAIT
>  CLEAR
>  RETURN
> ELSE
>  USE CST INDEX CSTNNDX
> ENDIF
> 
> This will output the string, but no information is returned from LKSYS(). I
think what it boils down to is that I am not sure how to check the file for lock
and what conditions will LKSYS() return information.

What happens if you change FLOCK() to RLOCK() (just for grins)? I am not 
sure if RLOCK() writes anything to those values, although I would think 
it would.

Ken


-- 
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
Post Reply
Re: Proper Retrieval of Locking information
Mon, 03 Dec 2007 10:47:42 -050
Geoff,
 
Q: Are you at the first record of the table when you check?
A: I don't think so. The error occurs when re-running a plain USE command.
 
Q: Which version of dBASE are you using?
A: dBase for DOS 5.0

Q: Which version of Windows is this?
A: Windows XP Professional

Q: What type of networking?
A: Client-Server Network. The server is running Windows Server 2003 Standard R2
SP2.

Q: Can you show us a sample of your code that you are using for attempting to
lock the table and for using LKSYS()?
A: Right now, the code calls a table index with the comand: USE CST INDEX
CSTNNDX. Which locks the CST database file. So when running in our environment,
a user will run the program that locks the file and then another user will try
to run the same program. Currently, in this scenario our very basic error
trapping routine is called. Which displays 108 File in use by another.

This is a small bit of logic I wrote from examples found, I just wanted the
LKSYS() to output whatever it had.

If FLOCK () == .F.
 ? "File Locked on " + LKSYS(0) + LKSYS(1) + LKSYS(2) + LKSYS(3) +
LKSYS(4) + LKSYS(5)
 WAIT
 CLEAR
 RETURN
ELSE
 USE CST INDEX CSTNNDX
ENDIF

This will output the string, but no information is returned from LKSYS(). I
think what it boils down to is that I am not sure how to check the file for lock
and what conditions will LKSYS() return information.

Thanks for looking at everything,
Matthew
Post Reply
Re: Proper Retrieval of Locking information
Tue, 4 Dec 2007 00:47:36 -0500
In article <u6wRXPcNIHA.1404@news-server>, mrockhold@walzeq.com says...
> Geoff,
>  
> Q: Are you at the first record of the table when you check?
> A: I don't think so. The error occurs when re-running a plain USE command.

The documentation suggests the information when you use FLOCK is stored 
in the first row. Try using GO TOP before checking LKSYS().

  
> Q: Which version of dBASE are you using?
> A: dBase for DOS 5.0
> 
> Q: Which version of Windows is this?
> A: Windows XP Professional
> 
> Q: What type of networking?
> A: Client-Server Network. The server is running Windows Server 2003
Standard R2 SP2.
> 
> Q: Can you show us a sample of your code that you are using for attempting
to lock the table and for using LKSYS()?
> A: Right now, the code calls a table index with the comand: USE CST INDEX
CSTNNDX. Which locks the CST database file. So when running in our environment,
a user will run the program that locks the file and then another user will 
try to run the same program. Currently, in this scenario our very basic error
trapping routine is called. Which displays 108 File in use by another.
> 
> This is a small bit of logic I wrote from examples found, I just wanted the
LKSYS() to output whatever it had.
> 
> If FLOCK () == .F.
>  ? "File Locked on " + LKSYS(0) + LKSYS(1) + LKSYS(2) + LKSYS(3)
+ LKSYS(4) + LKSYS(5)
>  WAIT
>  CLEAR
>  RETURN
> ELSE
>  USE CST INDEX CSTNNDX
> ENDIF
> 
> This will output the string, but no information is returned from LKSYS(). I
think what it boils down to is that I am not sure how to check the file for lock
and what conditions will LKSYS() return information.
> 
> Thanks for looking at everything,
> Matthew



Matthew,

When you do this:

use yourTable
list structure

do you see _DBASELOCK?


-- 
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.|        dBASE info at http://geocities.com/geoff_wass       |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
Post Reply
<< Previous 1 2 3 4 5 6 7 8 Next >>
( Page 1 of 8 )
about | contact