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: screen 1000 25: mode=system(7) 26: 27: createfont 1,60,0,0,0,0,0,0,0,0,0,0,0,0,"" 28: createfont 2,14,0,0,0,0,0,0,0,0,0,0,0,0,"" 29: selectfont 1 30: xsize=dlen("00:00:00") 31: rem 32: rem See if we have written out initialization parameters 33: rem 34: l=len(dir$("marks.stu")) 35: if l>0 then 36: open "marks.stu" for input as #1 37: input #1,leftx,topy,offset 38: close #1 39: else 40: leftx=0 41: topy=0 42: end if 43: 44: rem 45: rem size window 46: rem 47: 48: position leftx,topy,xsize+1-(xsize/9),60 49: 50: 51: rem 52: rem make background red 53: rem 54: 55: line (0,0)-(xsize+1-(xsize/9),60),4,bf 56: color 7,4 : rem this command would not be so flexible if we were 57: rem in another graphics mode (e.g. 8). 58: 59: 60: gosub makebuttons 61: mouseflag=mouseon 62: 63: 64: t$="" 65: quartersec=5 66: 67: 68: rem 69: rem Now we enter a perpetual loop to update time 70: rem 71: 72: 100 73: tt$=time$ 74: 75: if left$(tt$,5)<>t$ then 76: t$=left$(tt$,5) 77: gosub drawhourmin 78: end if 79: 80: sec=val(right$(tt$,2)) 81: sec=int(sec/15) 82: if sec<>quartersec then 83: if quartersec=5 then 84: for quartersec=0 to sec 85: gosub drawsec 86: next quartersec 87: else 88: quartersec=sec 89: gosub drawsec 90: end if 91: end if 92: 93: rem 94: rem check for button push 95: rem 96: a$=inkey$ 97: if len(a$)>1 then 98: if asc(right$(a$,1))=59 or asc(right$(a$,1))=60 then 99: rem + pushed 100: if asc(right$(a$,1))=59 then 101: offset=offset+1 102: if offset>30 then offset=30 103: else 104: offset=offset-1 105: if offset<-30 then offset=-30 106: end if 107: ix=xsize-((xsize/8)*2) 108: iy=40 109: ix=ix-10 110: iy=iy-10 111: line (ix,iy)-(ix+20,iy+20),4,BF 112: selectfont 2 113: locate iy,ix 114: print str$(offset); 115: selectfont 1 116: gosub drawhourmin 117: open "marks.stu" for output as #1 118: print #1, x,y,offset 119: close #1 120: end if 121: end if 122: goto 100 123: 124: 125: 126: rem 127: rem routine to draw hour/min 128: rem 129: rem on input tt$ has 5 chars for hour/min 130: rem 131: 132: drawhourmin: 133: 134: ttt$=left$(tt$,5) 135: if offset<>0 then 136: h=val(left$(ttt$,2)) 137: m=val(right$(ttt$,2)) 138: m=m+offset 139: if m>59 then 140: m=m-60 141: h=h+1 142: if h=24 then h=0 143: elseif m<0 then 144: m=m+60 145: h=h-1 146: if h<0 then h=23 147: end if 148: m$=str$(m) 149: l=len(m$) 150: m$=right$(m$,l-1) 151: 152: if len(m$)<2 then m$="0"+m$ 153: if len(m$)>2 then m$=right$(m$,2) 154: h$=str$(h) 155: l=len(h$) 156: h$=right$(h$,l-1) 157: if len(h$)<2 then h$="0"+h$ 158: if len(h$)>2 then h$=right$(h$,2) 159: ttt$=h$+":"+m$ 160: end if 161: locate 0,0 162: print ttt$; 163: return 164: 165: 166: rem 167: rem draw second 168: rem 169: rem quartersec has 1/4 min 170: rem 171: 172: drawsec: 173: 174: x=xsize-((xsize/8)*2) 175: y=40 176: if quartersec=0 then 177: circle (x,y),10,12 178: paint (x,y),12 179: circle (x,y),10,7,-.01,-3.1416/2 180: paint (x+2,y-2),7 181: elseif quartersec=1 then 182: circle (x,y),10,6,-4.7124,-.01 183: paint (x+2,y+2),6 184: elseif quartersec=2 then 185: circle (x,y),10,5,-3.1416,-4.7124 186: paint (x-2,y+2),5 187: elseif quartersec=3 then 188: circle (x,y),10,3,-3.1416/2,-3.1416 189: paint (x-2,y-2),3 190: gosub checkposition 191: end if 192: return 193: 194: 195: 196: rem 197: rem check and see if window position has changed. If so write new 198: rem position to my initialization file 199: rem 200: 201: checkposition: 202: x=system(8) 203: y=system(9) 204: if x<>leftx or y<>topy then 205: open "marks.stu" for output as #1 206: print #1, x,y,offset 207: close #1 208: end if 209: return 210: 211: 212: 213: 214: makebuttons: 215: rem 216: rem define buttons 217: rem 218: 219: px=xsize-((xsize/8)*3)+4 220: py=10 221: CBUTTON "+",1059,0,"Push",0,px+5,py,16,14,7,1 222: cbutton "-",1060,0,"Push",0,px+25,py,16,14,7,1 223: return 224: |