home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / libbasic / clock.bas < prev    next >
BASIC Source File  |  1994-04-23  |  2KB  |  63 lines

  1.  
  2.  
  3.     'clock1.bas  - a clock program for Liberty BASIC 1.0
  4.  
  5.     WindowWidth = 120
  6.     WindowHeight = 144
  7.     nomainwin
  8.     open "Clock" for graphics_nsb_nf as #clock
  9.     print #clock, "trapclose [exit]"
  10.  
  11.     for angle = 0 to 330 step 30
  12.         print #clock, "up ; home ; north ; turn "; angle
  13.         print #clock, "go 40 ; down ; go 5"
  14.     next x
  15.  
  16.     print #clock, "flush"
  17.  
  18. [timeLoop]
  19.  
  20.     while TrapClose <> "true"
  21.         time$ = time$()
  22.         hours = val(time$)
  23.         if hours > 12 then hours = hours - 12
  24.         minutes = val(mid$(time$, 4, 2))
  25.         seconds = val(right$(time$, 2))
  26.         ' if seconds has changed, then redraw the hands
  27.         if seconds <> oldSeconds then gosub [display]
  28.     wend
  29.     TrapClose = ""
  30.     goto [exit]
  31.  
  32. [display]  ' call this only when seconds has changed
  33.  
  34.     ' delete the last drawn segment, if there is one
  35.     if segId > 2 then print #clock, "delsegment "; segId - 1
  36.  
  37.     ' center the turtle
  38.     print #clock, "up ; home ; down ; north"
  39.  
  40.     ' erase each hand if its position has changed
  41.     if oldHours <> hours then print #clock, "size 2 ; color white ; turn "; oldHours * 30 + int(oldMinutes/2) ; " ; go 19 ; home ; color black ; north" : oldHours = hours
  42.     if oldMinutes <> minutes then print #clock, "size 2 ; color white ; turn "; oldMinutes * 6 ; " ; go 38 ; home ; color black ; north" : oldMinutes = minutes
  43.     if oldSeconds <> seconds then print #clock, "size 1 ; color white ; turn "; oldSeconds * 6 ; " ; go 38 ; home ; color black ; north" : oldSeconds = seconds
  44.  
  45.     ' redraw all three hands, second hand first
  46.     print #clock, "size 1 ; turn "; seconds * 6 ; " ; go 38"
  47.     print #clock, "size 2 ; home ; north ; turn "; hours * 30 + int(minutes/2); " ; go 19"
  48.     print #clock, "home ; north ; turn "; minutes * 6 ; " ; go 38"
  49.  
  50.     ' flush to end segment, then get the next segment id #
  51.     print #clock, "flush"
  52.     print #clock, "segment"
  53.     input #clock, segId
  54.  
  55.     return
  56.  
  57. [exit]
  58.  
  59.     confirm "Quit Clock?"; q$
  60.     if q$ = "no" then [timeLoop]
  61.     close #clock
  62.     end
  63.