Zhelkus Posted April 22, 2008 Posted April 22, 2008 First off, I want to make it clear that I'm a perfect noob just in case my question sounds dumb. I'm making a UDF that'll convert the result returned from a Timer() function into a neat [seconds,minutes,hours,days] format. Currently, I'm having trouble making the function return an array. How do I make it work? Here's the code: Func TimerResultNeatify($timerresult) Local $seconds = 0 Local $minutes = 0 Local $hours = 0 Local $days = 0 $seconds = Round($timerresult / 1000) While $seconds > 60 $seconds -= 60 $minutes += 1 WEnd While $minutes > 60 $minutes -= 60 $hours += 1 WEnd While $hours > 24 $hours -= 24 $days += 1 WEnd Return $seconds, $minutes, $hours, $days EndFunc ;==>TimerResultToTime
smashly Posted April 22, 2008 Posted April 22, 2008 (edited) Hi, I've not tested it;$aTime[0] = seconds ;$aTime[1] = minutes ;$aTime[2] = hours ;$aTime[3] = days Func TimerResultNeatify($timerresult) Local $aTime[4] $aTime[0] = Round($timerresult / 1000) While $aTime[0] > 60 $aTime[0] -= 60 $aTime[1] += 1 WEnd While $aTime[1] > 60 $aTime[1] -= 60 $aTime[2] += 1 WEnd While $aTime[2] > 24 $aTime[2] -= 24 $aTime[3] += 1 WEnd Return $aTime EndFunc ;==>TimerResultToTime Cheers Edit: Corrected some errors, I think ..lol Edited April 22, 2008 by smashly
Zhelkus Posted April 22, 2008 Author Posted April 22, 2008 Awesome! Thanks a lot! It actually looks even tidier
weaponx Posted April 22, 2008 Posted April 22, 2008 Looks similar to TicksToTime: #Include <Date.au3> _TicksToTime($iTicks, ByRef $iHours, ByRef $iMins, ByRef $iSecs)
Zhelkus Posted April 22, 2008 Author Posted April 22, 2008 Looks similar to TicksToTime: #Include <Date.au3> _TicksToTime($iTicks, ByRef $iHours, ByRef $iMins, ByRef $iSecs) I don't think I should post this script in the Example Scripts forum because every script there seems to be "on a higher level"
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now