Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Time Elapsed function: Answered my own question.
Message
 
À
17/07/1997 18:41:54
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00040258
Message ID:
00040536
Vues:
30
Egads! You are right :). I cut and pasted a previous version of the program without all my changes. Heh, you had me looking at that code for an hour trying to figure out what I did wrong before I noticed the one I pasted here was old. :-P. If anyone is interested I can paste the final version.


>No, your code has several typo bugs (you use xHour and XHours as one variable, xElpased and xElapsed as one variable, etc). But even if I fix these, the code still fails if you call it with (0,30), (0,3600), (0,3605), (3610,3615), etc. Because in some cases xHours and xMin are not initialized.
>
>Try for your self... :(
>
>BTW, for your example the xElapsed is 7234 and the functions fails because xMin was not initialized (as I already told you, when the hours or minutes part is/are zero).
>
>Vlad
>
>>The code works fine in all cases. This converts the seconds to hours, mintues, and seconds, so the output will look something like: 2h 0m 34s.
>>
>>
>>>Your code fails if the number of hours or minutes is zero.
>>>
>>>Vlad
>>>
>>>>Well, I hate sloppy code, so here is the new code using the SECONDS() function. It is considerably smaller:
>>>>
>>>>****************************************************************************
>>>>Procedure R_TimeElapsed &&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>>>****************************************************************************
>>>>PARAMETERS pTimeStart,pTimeEnd
>>>>
>>>>PRIVATE xElapsed,xSec,xMin,xHour,xReturn
>>>>
>>>>if pTimeStart > pTimeEnd
>>>> xElapsed = (24*60*60)-pTimeStart+pTimeEnd
>>>>else
>>>> xElapsed = pTimeEnd - pTimeStart
>>>>endif
>>>>
>>>>if xElapsed >= 3600
>>>> xHours = Int(xElapsed/3600)
>>>> xElpased = xElapsed - (3600*xHours)
>>>>endif
>>>>if xElapsed >= 60
>>>> xMin = Int(xTime/60)
>>>> xElapsed = xElapsed - (60*xMin)
>>>>endif
>>>>xSec = xElapsed
>>>>xReturn = ALLTRIM(STR(xHour))+"h "+ALLTRIM(STR(xMin))+"m ";
>>>> +ALLTRIM(STR(xSec))+"s"
>>>>
>>>>Return xReturn

Michael G. Emmons
memmons@nc.rr.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform