News:

;) This forum is the property of Proton software developers

Main Menu

Simple elapsed timer in hours, minutes and seconds

Started by RGV250, Sep 23, 2025, 07:38 PM

Previous topic - Next topic

RGV250

Hi,
I needed to see how long the program had been running, normally I have had a series of counters if > 59 then etc for hours minutes and seconds. It worked but always seemed messy. I think I have come up with a really neat solution now.

    Include "Amicus18.inc"
       
    Dim SecondsCount As Dword
    SecondsCount = 0
   
    Dim Hours As Word
    Dim Minutes As Byte
    Dim Seconds As Byte

       
Do
    HMS(SecondsCount)  ' Extract Hours, Minutes & Seconds
' Display total seconds, Hours, Minutes & Seconds.   
    HSerOut ["Elapsed time : ",Dec SecondsCount, " - ",Dec Hours,":",Dec Minutes, ":",Dec Seconds, 13] 
    Inc SecondsCount

    DelayMS 1000

Loop

' Procedure to convert seconds into running time, Hours, Minutes & seconds.
Proc HMS(pParam As Dword)
    Dim Temp As Dword
    Hours = pParam / 3600    ' Calculate the hours
    Temp = pParam // 3600    ' Calculate the remainder
    Minutes = Temp / 60      ' Calculate the minutes
    Seconds = Temp // 60     ' Calculate the remainder for the seconds
EndProc     


OK, it will not be that accuare if there is a lot going on but for my purposes it is ideal.

Bob