Alarm Clock RRS feed

All replies

  • Nice work.

    I know you hide the window during countdown, but here is an idea for a countdown phase before the alarm goes off.  When this While loop is completed the alarm is ready to go off.  The While loop ends when (hour1 <> Clock.Hour Or minutes1 <> Clock.Minute) is FALSE.  This only happens when (hour1 = Clock.Hour And minutes1 = Clock.Minute) so no further checking of the time is required - just start the alarm.

    Also it would be good after the alarm has gone off to try not to virtually repeat the Snooze code twice, perhaps a Subroutine could help here.  If you can manage to use Subroutines rather than lots of GoTo's this generally makes for easier code to follow, but sometimes the odd GoTo is very useful.

    'Do a countdown while waiting
    While (hour1 <> Clock.Hour Or minutes1 <> Clock.Minute)
      hourRemain = hour1-Clock.Hour 'Hours remaining
      minRemain = minutes1-Clock.Minute ' Minutes remaining
      secRemain = 0-Clock.Second ' Seconds remaining
      If (secRemain < 0) Then 'If we have less than 0 seconds left, then take it off the minute (THIS IS MOSTLY TRUE)
        secRemain = secRemain+60
        minRemain = minRemain-1
      If (minRemain < 0) Then 'If we have less tha 0 minutes left, then take it off the hour
        minRemain = minRemain+60
        hourRemain = hourRemain-1
      If (hourRemain < 0) Then 'If we have less than 0 hours left then take it off the day
        hourRemain = hourRemain+24
      TextWindow.CursorLeft = 0
      TextWindow.CursorTop = 0
      TextWindow.WriteLine(hourRemain+" hours "+minRemain+" minutes "+secRemain+" seconds left      ")

    Thursday, November 5, 2009 9:05 PM