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

Locking files

Status
Not open for further replies.

gfrgfr

Programmer
May 20, 2003
2
NL
I use two different programs and one datafile.
How can i check , before writing, if a file is locked.

gr.
GFR
 
Not tried any, but seen recently:

Thread
thread222-552812
 
What kind of datafile? Random access or a text file? Do you you want to lock individual records, or the whole table. Do you want to lock the read or a write or both?


David Paulson

 
Have you already checked the help files?

If not, click HELP > INDEX > (press the letter O) > (press down arrow until the "OPEN (File I/O) Statement" > (press enter).

It's tells you right in there. Take the time to read it and you'll come across it.

<hint: it says LOCK>
--MiggyD
 
Hi David,
i use a random file. The problem i described is the use of table and file locking.
How can I check if a table or file is locked. (before writing)
 
Excel, Word, etc... use a simple method...

for a given file...
File.Doc

when being edited it creates a...
~File.Doc

containing the text name of who is editing it (has the file locked)

if the ~filename is found when attempting to open filename it opens ~filename reads the user
then returns the message:
filename is locked for editing by user

Hope This Helps...
Good Luck

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
This should give you an idea of what your pgm should look something like.


'beginning of pgm
on error goto 60000
.
.
.
'open file
inven = freefile
open &quot;inventor.dat&quot; for random shared as #inven len = 256
.
.
.
.
'get a record from the table and lock it
lock inven, recordnumber
get inven, recordnumber
'
'do some stuff
'
'write data back to file
put inven, recordnumber
'don't forget to unlock record
unlock inven, recordnumber


60000 if err = 63 or err = 70 then print &quot;record locked - wait&quot;;: resume
'more error routines here

David Paulson

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top