hexagon logo

Runtime script with inexplicable results...

I have a function in my scripts to calculate the runtime in seconds for a program, using the Timer value from windows, which returns the current time as seconds from midnight.

The blue code is my script run at the beginning of a part program. The red code is what is run at the end. (I've cut and pasted these sections from the scripts...they are too long.) In the event that a program runs through midnight, I have a section in the red code to correctly calculate runtime. I've tested this code in the excel editor while resetting my computer clock to 11:59 PM and running it through midnight, and it works. Unfortunately, this code does not work when running PC-DMIS through midnight. I get program times of more than 86400.

Any ideas why this is not calculating correctly only when run through PC-DMIS?

[COLOR="Blue"]Sub Main()

Dim BeforeTime As String
BeforeTime = Timer
BeforeTime = CLng(BeforeTime)

End Sub[/COLOR]

[COLOR="Red"]
Sub Main()

Dim Aftertime As String
Aftertime = Timer
Aftertime = CLng(Aftertime)
Dim RunTime As String

If Aftertime < BeforeTime Then
RunTime = (86400 - BeforeTime) + Aftertime
Else
RunTime = Aftertime - BeforeTime
End If

End Sub[/COLOR]
Parents
  • I din’t know if to hijack this thread or start my own, but this is what I use to try and keep track of the lenght each program runs. It is in Hrs, Mins, Secs. Although I don’t think hrs has ever been anything above zero.

    This goes in the beginning of the program.
    ASSIGN/STARTTIME=INT(SYSTEMTIME("HH") * 3600) + INT(SYSTEMTIME("mm") * 60) + INT(SYSTEMTIME("ss"))


    This goes in the end of the program.
    ASSIGN/TOTALTIME=(INT(SYSTEMTIME("HH") * 3600) + INT(SYSTEMTIME("mm") * 60) + INT(SYSTEMTIME("ss")) - STARTTIME) / 60
                COMMENT/REPT,"RUN TIME = "+TOTALTIME+" MINUTES"


    This little code will place the actual run time in the report. If it means anything to anyone, If not I’ll just crawl back to my corner lol.
Reply
  • I din’t know if to hijack this thread or start my own, but this is what I use to try and keep track of the lenght each program runs. It is in Hrs, Mins, Secs. Although I don’t think hrs has ever been anything above zero.

    This goes in the beginning of the program.
    ASSIGN/STARTTIME=INT(SYSTEMTIME("HH") * 3600) + INT(SYSTEMTIME("mm") * 60) + INT(SYSTEMTIME("ss"))


    This goes in the end of the program.
    ASSIGN/TOTALTIME=(INT(SYSTEMTIME("HH") * 3600) + INT(SYSTEMTIME("mm") * 60) + INT(SYSTEMTIME("ss")) - STARTTIME) / 60
                COMMENT/REPT,"RUN TIME = "+TOTALTIME+" MINUTES"


    This little code will place the actual run time in the report. If it means anything to anyone, If not I’ll just crawl back to my corner lol.
Children
No Data