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

FPD 2.6a DOS -Application is still opened- files access denied

Status
Not open for further replies.

Foxtech

Programmer
May 26, 2001
66
0
0
CA
Hi everyone,

I would like to schedule an other dayend.APP to reindex my DBFs every night but sometime users forgot to quit the Account.APP from their workstation so the database is opened.

Do you know any solutions to solve this problem? What can I have to check for in my dayend.app, please advise.

in my dayend.app, I have tried to open the file

use customer
reindex

use dbf2
reindex

use dbf3
reindex

I've got the message files access denied and the program bombs.


thanks a lot
FoxTech
 
See faq182-4156 on creating a comphrehensive user friendly error routine. If you just need something simple, then try this code. You can make it a flexible subroutine that you just pass the name of the file to. Depends on what you want to do if the table won't open, report it, do something else or just continue. Remember that if you already have ON ERROR specified, then you'll have to save that beforehand and reset it afterwards. Probably a keyword search on this forum will give additional ideas.
Code:
myTable = "customer"

ON ERROR ErrorMsg = "Error "+LTRIM(STR(ERROR()))+" "+MESSAGE()
use (myTable)
* Reset or turn off error handler depending on your needs
ON ERROR
* If error #1705 then text is "File access denied." in FoxPro
* If error #1705 then text is "File access is denied." in Visual FoxPro
IF LEN(ALIAS()) > 0
   REINDEX
ELSE
   *** ? ErrorMsg  && failed to open for listed reason
ENDIF

dbMark
 
Of course, many here will also say the users should have logged off before they went home. If it's managers, well they should know better too and set a better example for the rest.

<tease> Once you start making them buy you lunch every time they do go home with the program open, they'll learn. Or maybe not. </tease>
 
Another method of managing personnel who won't do as required is to make EVERYONE wait the next morning until the re-index is complete.

Oh yes, also be sure to let all other users know who's "mistake" it was that made them all wait. That typically gets the appropriate changes put into place.

In lieu of that you can find "generic" Windows programs on the web which will execute a variety of tasks in an automated manner. These might be used on the individual's workstations to force an End Task of the FP application if it should be left running.

However, be cautious -- an abrupt termination of FP applications without programatically closing data tables, etc. has a nasty habit possibly corrupting indexes, memo fields, etc. in tables. With that in mind, perhaps managing personnel's habits might be a better approach.

There is one other possibility. If you are creating the application yourself and can add additional functionality, you can set up TIMEOUT's, etc. which will close things on workstations if they are left un-attended too long, or add a function which can be checked to see if a certain time of day has passed, such as 11:59 PM after which the application closes everything and QUIT's.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
You can't programmatically kick out the other users. However, you can make your program bomb at a better spot. Since you are in a multi user environment, perhaps you have EXCLUSIVE set OFF. I'd recommend opening the files you are going to index with

USE (file) EXCLUSIVE

That way, you can't even USE the file unless all other users are out.
 
I would approach this from the point that your dayend app can only run if exclusive file use is available. To do this I would suggest you use, if you don't already, a user log file in your primary app. This can be a very simple table that appends a user name or node and also applies an RLOCK() to that entry in the main of that app. Because Rlock() is automatically released when a user logs off your dayend app can poll this table at various times and check for locks. If a lock exists then dont try and run dayend, if it doesnt then you know no one is logged in so run dayend exclusively.

Bob Palmer
The most common solution is H2O!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top