Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


How to Display a Countdown Clock

Keywords:   countdown clock

Question:

Was wondering if anyone out there has come out with a way of displaying a "countdown clock" on the screen while waiting for an event to happen?

What I am trying to do is cause a delayed shutdown (which is easy) but keep the user apprised of how much time is left (which isn't). Tried some of the timing functions but they were not able to update the screen rapidly enough. Would like this to countdown per second or two if possible.

Answer:

Something like this, with a little "tweaking" ....
time=10

BoxOpen("CountDown","")
stopped=0

while time > 0
   BoxText(strcat("Time left = ",time,@crlf,"Hit shift key to stop countdown"))
   TimeDelay(1)
   if IsKeyDown(@shift)
      stopped=1
      break
   endif
   time=time-1 
endwhile
if stopped==1
   Message("Countdown","Stopped by user")
else
   Message("Countdown","Timed Out")
endif
exit

Article ID:   W13212
Filename:   Display a Countdown Clock.txt