|
time
Mar 22, 2011 16:55:15 GMT -5
Post by roboticmehdi on Mar 22, 2011 16:55:15 GMT -5
Hello programmers. I want somehow to be able to know how much time have passed since my program has been running. Is there any function for that? Or is there a function to get current time. That way i could get the time at the beginning and get the time during program and find out how much time have passed. i guess it would look like: gettime(h,m,s,ms) where h=hour, m=minute, s=second, ms=millisecond all are integers. Please help me
|
|
|
time
Mar 22, 2011 18:39:34 GMT -5
Post by matthew on Mar 22, 2011 18:39:34 GMT -5
Hi robot an extremely simple way is to use the tickcount() command.
dim t
t = tickcount()
textmode(text_buffered)
do
' do work here cls : print "Time: " ; (tickcount() - t) / 1000.0 drawtext()
loop
You could improve it by storing the result of tickcount() in a variable called sec then check to see if it has reached 60. If it has just increment another variable called min by 1.
|
|
|
time
Mar 22, 2011 19:36:06 GMT -5
Post by roboticmehdi on Mar 22, 2011 19:36:06 GMT -5
Thank you very much !! it works, huh We know that t is 32 bit integer so the maximum value that it can handle is 2^32. I calculated the time it can show. 2^32/(1000) seconds 2^32/(1000*60) minutes, divide by 60 = hours, divide by 24= days. the answer is = 49.7 days. we must divide this result by two since integer handles negative values also. 49.7/2=25 ( approximately) what if my computer has been running more that that ?
|
|
|
time
Mar 22, 2011 20:48:01 GMT -5
Post by matthew on Mar 22, 2011 20:48:01 GMT -5
Ah well then you could always download the Time Plugin which you will find in this thread. That will tell you what the actual time is & you can use the information to calculate how long your application has been running for.
|
|