Getting Program To End After USer Defined Length of Time
[pbcode]
; 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
[/pbcode]