Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP 5.0 bug ??? What happend with Seconds() ??????
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00178833
Message ID:
00178870
Views:
17
>Hi all,
>I have a form with 2 text boxes: one for time of start th process and the other for the elapsed time. Also, I have a command button to start the process
>
>At the cmdStart.click() method I put the fllow code:
>
nStartTime = Seconds()
>dStartDate = Date()
>thisform.txtStartTime.Value = ssTohh( nStartTime )
>thisform.txtElapsed.Value = ssTohh( 0 )
>...
>*** Process Begin
>...
>Do While <I>main condition</i>
>    ...
>    nDiff = Date() - dStartDate
>    nSeconds = Seconds()
>    nElapsed = (nDiff*86400) + nSeconds - nStartTime
>    thisform.txtElapsed.Value = ssTohh( nElapsed )
>    ...
>EndDo
>
>ssTohh is a function that convert seconds to hh:mm:ss
>This code work Fine if run in the same day, but...
>If I run the process before midnight, when the day change, VFP crash.
>
>Is this a VFP 5.0 bug ????
>Please try to test this code and help me! I need to run a process at 23:00 every day and it take 1 or 2 hours and the client want to know the elapsed time.
>
>Thaks in advance for your time!!!!!!!

Hello Bruno!

I guess the problem is in ssTohh function. What does your function do, when get negativ number as parameter?
The problem is the following: To program lines could work on different days!!!

> nDiff = Date() - dStartDate && this line works on the original day
> nSeconds = Seconds() && this line works on the day after

So nDiff gets zero, and nSeconds is very small nunber.

> nElapsed = (nDiff*86400) + nSeconds - nStartTime
So, nElapsed is a negativ number!!!

I suggest you, to change the code to:
Make a variable, holding the last value of Seconds(), and compare to its actual value: (nLastSeconds)
if nSeconds nDiff = Date() - dStartDate
endif
nLastSeconds=nSeconds

This program structure guarantees, that nDiff can change if seconds has changed!!

BB
nElapsed = (nDiff*86400) + nSeconds - nStartTime
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform