home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / devtools / files / lb202win.exe / LB202W.EXE / CLOCK2.BAS < prev    next >
Encoding:
BASIC Source File  |  2000-12-05  |  2.0 KB  |  66 lines

  1.  
  2.  
  3.     'clock2.bas  - a clock program for Liberty BASIC 2.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.     print #clock, "fill white"
  12.     for angle = 0 to 330 step 30
  13.         print #clock, "up ; home ; north ; turn "; angle
  14.         print #clock, "go 40 ; down ; go 5"
  15.     next x
  16.  
  17.     print #clock, "flush"
  18.  
  19.     timer 1000, [display]
  20.     wait
  21.  
  22. [display]  ' call this only when seconds has changed
  23.  
  24.  
  25.     time$ = time$()
  26.     hours = val(time$)
  27.     if hours > 12 then hours = hours - 12
  28.     minutes = val(mid$(time$, 4, 2))
  29.     seconds = val(right$(time$, 2))
  30.  
  31.     ' delete the last drawn segment, if there is one
  32.     if segId > 2 then print #clock, "delsegment "; segId - 1
  33.  
  34.     ' center the turtle
  35.     print #clock, "up ; home ; down ; north"
  36.  
  37.     ' erase each hand if its position has changed
  38.     if oldHours <> hours then print #clock, "size 2 ; color white ; turn "; oldHours * 30 + int(oldMinutes/2) ; " ; go 19 ; home ; color black ; north" : oldHours = hours
  39.     if oldMinutes <> minutes then print #clock, "size 2 ; color white ; turn "; oldMinutes * 6 ; " ; go 38 ; home ; color black ; north" : oldMinutes = minutes
  40.     if oldSeconds <> seconds then print #clock, "size 1 ; color white ; turn "; oldSeconds * 6 ; " ; go 38 ; home ; color black ; north" : oldSeconds = seconds
  41.  
  42.     ' redraw all three hands, second hand first
  43.     print #clock, "size 1 ; turn "; seconds * 6 ; " ; go 38"
  44.     print #clock, "size 2 ; home ; north ; turn "; hours * 30 + int(minutes/2); " ; go 19"
  45.     print #clock, "home ; north ; turn "; minutes * 6 ; " ; go 38"
  46.  
  47.     ' flush to end segment, then get the next segment id #
  48.     print #clock, "flush"
  49.     print #clock, "segment"
  50.     input #clock, segId
  51.  
  52.     wait
  53.  
  54. [exit]
  55.  
  56.     timer 0   'prevent timer ticks from building up
  57.     confirm "Quit Clock?"; q$
  58.     if q$ = "yes" then
  59.         close #clock
  60.     else
  61.         timer 1000, [display]
  62.         wait
  63.     end if
  64.  
  65.     end
  66.