// Project: forever time
// Created: 2015-01-17
Setvirtualresolution(640,480)
ResetTimer()
// Check if file exists, if it does then read the stored UNIX time value,
// if not, create it and store current UNIX time/date in the file.
If GetFileExists("__timer__")
id=OpenToRead("__timer__")
oldtime=ReadInteger(id)
CloseFile(Id)
Else
date$=GetCurrentDate()
time$=GetCurrentTime()
unix=GetUnixFromDate(Val(Left(date$,4)),Val(Mid(date$,6,2)),Val(Right(date$,2)),Val(Left(time$,2)),Val(Mid(time$,4,2)),Val(Right(time$,2)))
id=OpenToWrite("__timer__")
WriteInteger(id,unix)
CloseFile(id)
oldtime=unix
EndIf
do
date$=GetCurrentDate()
time$=GetCurrentTime()
nowtime=GetUnixFromDate(Val(Left(date$,4)),Val(Mid(date$,6,2)),Val(Right(date$,2)),Val(Left(time$,2)),Val(Mid(time$,4,2)),Val(Right(time$,2)))
test=nowtime-oldtime
sec=Mod(test,60)
test=Floor(test/60)
min=Mod(test,60)
test=Floor(test/60)
hour=Mod(test,60)
Print(Str(hour)+" Hour "+Str(min)+" Min "+Str(sec)+" Sec")
Print("Since this app was first started")
Sync()
If Timer()>15 Then Exit
Loop
//To delete the timer file, uncomment the following line
//DeleteFile("__timer__")
End
Help make AGK better by submitting an example for this command! (All examples are subject to approval)
// Project: forever time // Created: 2015-01-17 Setvirtualresolution(640,480) ResetTimer() // Check if file exists, if it does then read the stored UNIX time value, // if not, create it and store current UNIX time/date in the file. If GetFileExists("__timer__") id=OpenToRead("__timer__") oldtime=ReadInteger(id) CloseFile(Id) Else date$=GetCurrentDate() time$=GetCurrentTime() unix=GetUnixFromDate(Val(Left(date$,4)),Val(Mid(date$,6,2)),Val(Right(date$,2)),Val(Left(time$,2)),Val(Mid(time$,4,2)),Val(Right(time$,2))) id=OpenToWrite("__timer__") WriteInteger(id,unix) CloseFile(id) oldtime=unix EndIf do date$=GetCurrentDate() time$=GetCurrentTime() nowtime=GetUnixFromDate(Val(Left(date$,4)),Val(Mid(date$,6,2)),Val(Right(date$,2)),Val(Left(time$,2)),Val(Mid(time$,4,2)),Val(Right(time$,2))) test=nowtime-oldtime sec=Mod(test,60) test=Floor(test/60) min=Mod(test,60) test=Floor(test/60) hour=Mod(test,60) Print(Str(hour)+" Hour "+Str(min)+" Min "+Str(sec)+" Sec") Print("Since this app was first started") Sync() If Timer()>15 Then Exit Loop //To delete the timer file, uncomment the following line //DeleteFile("__timer__") End