Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question on function
Message
 
To
21/06/1999 15:09:58
Dovi Gilberd
Dovtware Consulting Inc
Miami, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00232121
Message ID:
00232232
Views:
16
Dovi,

First where is answertime getting a value? You delcare it local tand then reference it for assinging values to hr1 etc. But you never give it a value. Second what is the Format of answertime, is it 999999 or 99:99:99?

If it is the latter format then your substr's are wrong, thy should be 1,2 then 4,2 then 7,2 respectively. This will cause zeros as it will return 0 as the value for the substr.

You can simplify the converstion to seconds by using 3600 for teh hours and 60 for the mintues instead of 60 * 60 for the hours.


>********************************************************************************
>function result() && Function to calculate time diference
>********************************************************************************
>parameters hrs1, min1, sec1, hrs2, min1, sec2, timesec1, timesec2, finaltime, timediff, result
>
>local answertime, endtime
>
>Hrs1 = VAL(SUBSTR ( answertime, 1, 2 ))
>Min1 = VAL(SUBSTR ( answertime, 3, 2 ))
>Sec1 = VAL(SUBSTR ( answertime, 5, 2 ))
>
>Hrs2 = VAL(SUBSTR ( endtime, 1, 2 ))
>Min2 = VAL(SUBSTR ( endtime, 3, 2 ))
>Sec2 = VAL(SUBSTR ( endtime, 5, 2 ))
>
>Time1Sec = ( 60 * 60 * Hrs1 ) + ( 60 * Min1 ) + Sec1
>Time2Sec = ( 60 * 60 * Hrs2 ) + ( 60 * Min2 ) + Sec2
>
>TimeDiff = Time2Sec - Time1Sec
>
>IF Hrs2 < Hrs1
> TimeDiff = (Time2Sec+(86400)) - Time1Sec
>ENDIF
>
>finaltime = (TimeDiff/60)+ 0.1
>
>IF finaltime < .6
> finaltime=.5
>ENDIF
>
>result= round(finaltime,1)
>&&store result to result
>return result
>EndFunc
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform