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

IS THIS POSSIBLE ?????

Status
Not open for further replies.

VNDN

Programmer
Feb 28, 2003
27
US
I have been assigned to maintain a application that had written in Clipper 5.2. and I am learning and making changes to application at the same time. And The scoop is that we constantly having an error "File is used by another" when support associates running a utility to reindex all the DBF files while someone else is also in the application. Is there any way to lock this down so that no one else can get to the files that being used when perform this function.
Please guide me. Again I have very little experience with clipper. Thank you. DN
 
Hi, VNDN

The short answer is no, it isn't possible.

Some functions, like pack and reindex require exclusive use of the file, because in order to perform the function the entire file has to be locked, which precludes any other user (or even another task in the same machine) accessing the file concurrently.

When you are going to do a reindex, you USE the file EXCLUSIVE and then test for a neterr() to see if you got it. If not, you put up a message (sounds like yours is defaulting to "File used by another") and go away. There is really nothing you can do about it.

In a production situation the solution is to keep the indexes up to date and avoid crashes etc which may corrupt them. Then it should only rarely be necessary to reindex.

Jock
 
Jock, VNDN,

In general terms you need exclusive access to pack and index in Clipper.

If you have an app to which you have the source it is well worthwhile putting some kind of semaphore system in to enable you to block/users or force them to wait at least while you pack and index.

Basically, when they ask to open the tables, check for the presence of a file - if it is there, ask them to wait.

When you want to reindex or pack, create the file and if you can't get exclusive access - wait yourself...

Clipper apps do need packing from time to time. The bigger the app the more you will be likely to need to do this - but how often is dependent on so many things it's not worth worrying about. I have one 40 user app which hasn't been reindexed in four years, and one single user apps that needs attention once a month (or it gets a bit slow) and another on a somewhat ropey network that gets packed overnight, every night.

HTH

Regards

Griff
Keep [Smile]ing
 
To add,

Most X-Base systems have a generic re-indexing routine that reads all tables and associated indices off a DBF (REINDEX.dbf) in our company's case.

It isn't too difficult to develop or source. You may like to look in the FoxPro thread also.

End
 
Hi,

I have created my own background task that schedules
such tasks as INDEX, PACK and HEADER AUDIT for overnight
and weekends. The scheduler (written in CLIPPER) also
handles tasks for MONTH-END and YEAR-END ageing and purging routines and cleardowns. Each scheduled task can be
re-scheduled by a nominated time interval into the future
(daily, weekly, calendar month) at a nominated 24 hour time.

Now my applications can be properly maintained by the users
with no disruption during their normal work hours... and
important tasks can not be omitted by thoughtless staff!

The scheduler checks if it is the SOLE USER to the system
(a control record keeps a count of logged in users) and
only begins a scheduled task if there is no danger of
conflict with other users active on the databases.

If you do not want to go to this trouble then your only alternative is as Jock and Griff have written above.

By the way - I NEVER use REINDEX.
The result is too uncertain and may retain a contamination!
Instead I erase the original index file and then
create a fresh index of the same name using the designated
fields for the key expression as follows:-
USE myfile EXCLUSIVE
IF <> NETERR()
erase myfile.ntx
INDEX ON field1 + field2 TO myfile
* display a success message
ELSE
* display an error message
ENDIF
Good Luck... no-one likes maintaining someone else's old
program code!

Jim Wild
T/A Wildcard Systems - New Zealand



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top