home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / WBB12.ZIP / SAMPLEG3.BAS < prev    next >
BASIC Source File  |  1992-09-08  |  5KB  |  232 lines

  1.  
  2.  
  3. rem
  4. rem This program is for WINDOWS use only.
  5. rem
  6. rem This program displays a digital clock, using a large font. For people
  7. rem with a pathological aversion to being late this clock allows you to
  8. rem 'offset' the time by some number of minutes.
  9. rem
  10. rem Startup position and our time offset our saved to a startup file
  11. rem so we will always start up correctly.
  12. rem
  13. rem We use the POSITION command to size our window.
  14. rem We use the CREATEFONT command to make our font.  Our requirements are
  15. rem    that it be 60 pixels high.
  16. rem
  17. rem We are going to let BasicBasic to repaint screen where necessary.
  18. rem
  19.  
  20.    rem windows size 30,9,50,11
  21.  
  22.    REM windows name "Mark's Clock"
  23.  
  24.  
  25.    rem
  26.    rem Before going into graphics mode say we are handling paint.  If we
  27.    rem wait and do this after SCREEN command then a big bitmap would be
  28.    rem created (during SCREEN command) and then deleted (during ON PAINT).
  29.    rem
  30.  
  31.    screen 1000
  32.    mode=system(7)
  33.  
  34.    createfont 1,60,0,0,0,0,0,0,0,0,0,0,0,0,""
  35.    createfont 2,14,0,0,0,0,0,0,0,0,0,0,0,0,""
  36.    selectfont 1
  37.    xsize=dlen("00:00:00")
  38.    rem
  39.    rem See if we have written out initialization parameters
  40.    rem
  41.    l=len(dir$("marks.stu"))
  42.    if l>0 then
  43.     open "marks.stu" for input as #1
  44.     input #1,leftx,topy,offset
  45.     close #1
  46.    else
  47.     leftx=0
  48.     topy=0
  49.    end if
  50.  
  51.    rem
  52.    rem size window
  53.    rem
  54.  
  55.    position leftx,topy,xsize+1-(xsize/9),60
  56.  
  57.  
  58.    rem
  59.    rem make background red
  60.    rem
  61.  
  62.    line (0,0)-(xsize+1-(xsize/9),60),4,bf
  63.    color 7,4 : rem this command would not be so flexible if we were
  64.            rem in another graphics mode (e.g. 8).
  65.  
  66.  
  67.    gosub makebuttons
  68.    mouseflag=mouseon
  69.  
  70.  
  71.    t$=""
  72.    quartersec=5
  73.  
  74.  
  75. rem
  76. rem Now we enter a perpetual loop to update time
  77. rem
  78.  
  79. 100
  80.    tt$=time$
  81.  
  82.    if left$(tt$,5)<>t$ then
  83.      t$=left$(tt$,5)
  84.      gosub drawhourmin
  85.    end if
  86.  
  87.    sec=val(right$(tt$,2))
  88.    sec=int(sec/15)
  89.    if sec<>quartersec then
  90.      if quartersec=5 then
  91.        for quartersec=0 to sec
  92.      gosub drawsec
  93.        next quartersec
  94.      else
  95.        quartersec=sec
  96.        gosub drawsec
  97.      end if
  98.    end if
  99.  
  100.    rem
  101.    rem check for button push
  102.    rem
  103.    a$=inkey$
  104.    if len(a$)>1 then
  105.     if asc(right$(a$,1))=59 or asc(right$(a$,1))=60 then
  106.      rem + pushed
  107.      if asc(right$(a$,1))=59 then
  108.        offset=offset+1
  109.        if offset>30 then offset=30
  110.      else
  111.        offset=offset-1
  112.        if offset<-30 then offset=-30
  113.      end if
  114.      ix=xsize-((xsize/8)*2)
  115.      iy=40
  116.      ix=ix-10
  117.      iy=iy-10
  118.      line (ix,iy)-(ix+20,iy+20),4,BF
  119.      selectfont 2
  120.      locate iy,ix
  121.      print str$(offset);
  122.      selectfont 1
  123.      gosub drawhourmin
  124.      open "marks.stu" for output as #1
  125.      print #1, x,y,offset
  126.      close #1
  127.     end if
  128.    end if
  129.    goto 100
  130.  
  131.  
  132.  
  133. rem
  134. rem routine to draw hour/min
  135. rem
  136. rem on input tt$ has 5 chars for hour/min
  137. rem
  138.  
  139. drawhourmin:
  140.  
  141.    ttt$=left$(tt$,5)
  142.    if offset<>0 then
  143.      h=val(left$(ttt$,2))
  144.      m=val(right$(ttt$,2))
  145.      m=m+offset
  146.      if m>59 then
  147.        m=m-60
  148.        h=h+1
  149.        if h=24 then h=0
  150.      elseif m<0 then
  151.        m=m+60
  152.        h=h-1
  153.        if h<0 then h=23
  154.      end if
  155.      m$=str$(m)
  156.      l=len(m$)
  157.      m$=right$(m$,l-1)
  158.  
  159.      if len(m$)<2 then m$="0"+m$
  160.      if len(m$)>2 then m$=right$(m$,2)
  161.      h$=str$(h)
  162.      l=len(h$)
  163.      h$=right$(h$,l-1)
  164.      if len(h$)<2 then h$="0"+h$
  165.      if len(h$)>2 then h$=right$(h$,2)
  166.      ttt$=h$+":"+m$
  167.    end if
  168.    locate 0,0
  169.    print ttt$;
  170.    return
  171.  
  172.  
  173. rem
  174. rem draw second
  175. rem
  176. rem quartersec  has 1/4 min
  177. rem
  178.  
  179. drawsec:
  180.  
  181.      x=xsize-((xsize/8)*2)
  182.      y=40
  183.      if quartersec=0 then
  184.        circle (x,y),10,12
  185.        paint (x,y),12
  186.        circle (x,y),10,7,-.01,-3.1416/2
  187.        paint (x+2,y-2),7
  188.      elseif quartersec=1 then
  189.        circle (x,y),10,6,-4.7124,-.01
  190.        paint (x+2,y+2),6
  191.      elseif quartersec=2 then
  192.        circle (x,y),10,5,-3.1416,-4.7124
  193.        paint (x-2,y+2),5
  194.      elseif quartersec=3 then
  195.        circle (x,y),10,3,-3.1416/2,-3.1416
  196.        paint (x-2,y-2),3
  197.        gosub checkposition
  198.      end if
  199.      return
  200.  
  201.  
  202.  
  203. rem
  204. rem check and see if window position has changed.  If so write new
  205. rem position to my initialization file
  206. rem
  207.  
  208. checkposition:
  209.     x=system(8)
  210.     y=system(9)
  211.     if x<>leftx or y<>topy then
  212.       open "marks.stu" for output as #1
  213.       print #1, x,y,offset
  214.       close #1
  215.     end if
  216.     return
  217.  
  218.  
  219.  
  220.  
  221. makebuttons:
  222.    rem
  223.    rem define buttons
  224.    rem
  225.  
  226.      px=xsize-((xsize/8)*3)+4
  227.      py=10
  228.      CBUTTON "+",1059,0,"Push",0,px+5,py,16,14,7,1
  229.      cbutton "-",1060,0,"Push",0,px+25,py,16,14,7,1
  230.      return
  231.  
  232.