News:

Function Finder  Find all the functions within source code files

Main Menu

Getting Program To End After USer Defined Length of Time

Started by kevin, September 29, 2010, 08:28:44 AM

Previous topic - Next topic

kevin


Getting Program To End After USer Defined Length of Time



PlayBASIC Code: [Select]
   ; Get the time that program loop started   
StartTime=Timer()

; Calc when we expect this program should end
; in this example we're taking the starting time
; and adding 10 seconds to it (in milliseconds)
EndTime=StartTime+(10*1000)

; Program Loop
Do

; Get the Current Time
CurrentTime =timer()

; Calc How much time has past since the program started
TimePast=CurrentTime-StartTime


; Clear The Screen
Cls

; display time past in seconds
print TimePast/1000

; Check if the current time is beyond our expected End time
; if so, print the out of time message and END
if CurrentTime>EndTime
print "Out Of Time"
Sync
waitkey
end
endif


; Refresh the screen
Sync

; Loop back to the do statement to keep this program running
; in a loop
loop