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!

test for a modified table 1

Status
Not open for further replies.

HowardHammerman

Instructor
Oct 11, 2001
640
0
0
US
I have a Visual FoxPro routine that issues a RUN command to an external program that, in turn,zaps a table and then re-populates it with current data.
The VFP program then goes on to do some more work and then needs to use the newly populated table.

I have a problem in timing. If the external program is not done by the time it needs to be used, I get an understanable error.

Is there a FoxPro command to test on the modification date/time, or if the file is current open?

Thanks,


Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
Hi Howard,

Well FDATE([filename]) will give you the modification date (or datetime), FOPEN([filename],12) can return whether or not the file is availble to write to (and so whether the routine has finished).

However I have to ask why are you using the RUN command to an external program to do something that it seems you could do from the calling routine. Also, if you are going to run an external program, have you thought about using the API call ShellExecute()?

Hope that helps,

Stewart
 
While I'd recommend another approach you can use the ADIR() command to determine the Date/Time of when a file was last modified.

I would personally recommend adding one or more fields to the table itself and capture the Date/Time of when each record was added/modified and then have the application use that instead.

Knowing if a file is in use is more complicated.

You could set up an ERROR handler to not 'bomb' out and then attempt to use the table EXCLUSIVE.

If it opened, then you would be the only one using it. If an error was thrown, then someone else had the table in use.

Good Luck,
JRB-Bldr
 
Hi Howard,

Good to see you here again.

Here's a possible way of achieving what you want:

Code:
oWSH = CREATEOBJECT('wscript.shell')
oWSH.Run('MyExernalProg.EXE', 1, .T.)

Basically, this will run an external program, and only return control to the calling program when the external program has finished.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thank you guys. I especially like Mike Lewis's approach since it simply want my program to wait until the external is done. And to answer Stewart's question, the reason I am running an exeternal program is becuase I am a lousy programmer (a much better analyst) and I am using R&R Report writer to do the heavy lifting and create a reference dataset.

Thanks again.

Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top