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

Elapsed Time Message

Status
Not open for further replies.

dzdncnfsd

MIS
Jul 14, 2000
118
US
I need to know the amount of time it takes a program to run and I don't want to have to time it myself. Is there any way to put a procedure or function in my program that will pop up a message window when the program is done and have it say something like: "This program took N hours and N minutes to run." This is for my use only and I am running the program from within Visual FoxPro.
Thanks,
Gladys


Gladys Clemmer
gladys.clemmer@fifsg.com

 
At the appropriate point, place a line like: starttime=seconds(). Just before the program ends you can use the line elapsed_time=seconds()-starttime to get the total time. If you want it broken down into Hrs/Mins/Secs you can operate on the total number of seconds to return the appropriate text.
 
Or What I do to check on my programs that run unattended at night
[tt]
use nightly
scan all
prg2run = alltrim(nightly.program)
lnNiteRecno= recno
replace nightly.starttime with time(), nightlystartday with date()
do &prg2run
close data
use nightly
goto lnNiteRec
replace nightly.endtime with time(), nightly.endday with date()
endscan
report form nightly to print
[/tt]

David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
I prefer using the datetime() function. This eliminates one of steps dealing with either date or time.

 
Old Habits Die Hard, and I like the Rule: If it works don't F*()&*() with it. I wrote that routine over 10 years ago before the datetime field existed.

David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
I hear what Dave is saying. And by the replies he's given in this forum, he has my full respect and I'm hesitant to even partially disagree - but..

The datetime() function will save some code in determining the net time elapsed (you don't have to check whether it's gone past midnight).

I've seen (and you have too, I'll bet) too many programmers slowly become inefficient and outdated by reluctance to embrace new commands and programing styles.

It's a minor thing, but I'll vote for datetime().
 
I agree with both of you that the new function has advantages. If I had to write it from scratch I'd use the datetime function also. It is just that I have so many customers still running old code I wrote and several library files that depend in the date,time fields being 2 fields. I do not like to change things when I do not have to. <but>[red]just for fun and giggles[/red]<g>, I did not realise any code entered in this forum was made from concrete.

David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top