Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simulating Scheduled Tasks in VFP
Message
From
27/01/1999 23:09:19
 
 
To
27/01/1999 20:28:21
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00181129
Message ID:
00181173
Views:
14
Tom:

I did something like this for a client recently - created a form with a timer, set the timer to fire every so often. Worked really well, but don't have the code to send to you. The basic idea was:

1) Use a log file (dbf) to record the files that have been processed, capture the name, date/time, file size, etc. The import process would then compare the contents of the directory to the log and process any new files

2) One problem I faced early on was if the import process was already running when the timer fired - to fix, I added a "busy" flag to the form, and the timer checks this flag before calling the import routine. The import routine sets the busy flag when it starts and clears it when done.

3) Another problem I faced was files that were in use when I went to import them. To fix this, I copied the file contents to a temp file, then imported from the temp. If the file was in use, the copy failed, and I just skipped over the file.

4) I had a situation where file names were not unique day to day, so I used the date/time stamp and size fields to determine if the file in the directory was "new". If the date/time of the file is > the date/time captured in the log, the file must be "new".

5) As with any intensive loop, calls to DoEvents should be added as needed. I had one user who would use NT's Task Manager to test if the program was actually running, and if it said Not Responding, he killed it. Adding some DoEvents in the right places seemed to solve this.

Keep in mind that the temptation will be to keep the timer setting low and try and run the import routine as often as possible. You'll run into problems this way

Hope this helps
Rob

>How can I best set up a process that needs to run every hour?
>
>For instance, I need to run a program that goes out and checks
>for the existance of new files on a directory. If new files
>are found then a program will need to be run to import this
>data.
>
>Thus far, I have thought of something like the following:
>
> DO WHILE .T.
> lnx = ADIR(lax,'\searchdir\*.*')
> IF lnx > 0
> DO importprogram
> ENDIF
> ENDDO
>
>I suspect that the CPU useage will always be at 100% and
>a PC will need to be dedicated to only this task.
>
>Is there a better way to do this that can check every
>hour or so. Perhaps a class with a timer event.
>
>I suspect that someone has had to create something like
>this before... right?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform