10	 ! Logtot.bas
	 ! to total logged on time for a GIVEN FISCAL YEAR
	 ! this version does a bar graph output
	 ! for one terminal only
100 dim l$[56],n$[50]v,d1$[8],d2$[8],o1$[9],o2$[1](56),o3$[56]v,xd$[8]v,mo$[36]
101 dim da$[21],tt$[4]
105 mo$="JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
106 da$="SUNMONTUEWEDTHUFRISAT"
110 sd=24*3600	 ! seconds per day
120 OPEN #4, "LOGYEAR.DOC/WR"
125 set upper on
130 input "User Name ";n$
140 input "Terminal (TTnn) ";tt$
150 set upper off
200 print #4,"                                                          User Name ";n$
201 print #4, "                                                           Terminal ";tt$
205 n$=n$+".log/rn/ro/sh/ln:56"
208 cs=0 : cm=0 : ch=0 : cd=0:
	ts=0 : tm=0 : th=0 : td=0: ld=0
209 for jj=1 to 56 : o2$(jj)=" " : next jj
210 input "Fiscal Year to plot ";YR
212 IF yr<78 or yr >89 then print "invalid year" : goto 210
213 d1$="07/01/"+frmt$(yr-1,2) : df=dcen(d1$)
214 d2$="06/30/"+frmt$(yr,2) : dl=dcen(d2$)
215 print #4,"                                                      Starting Date ";d1$
216 print #4,"                                                         Final Date ";d2$
217 xd$=""
220 open #3,n$:
	n=nrc(3):
	 if n<6 then 1010
225 print #4 : print #4, "DAY DATE     6   7   8   9   10  11  12  13  14  15  16  17  18  19  20   TOTAL"
226 print #4, "--- -------- !   !   !   !   !   !   !   !   !   !   !   !   !   !   !"
230 lf=0:
235 xd$="00/00/00"
240 for i=6 to n
250 input line #3@i,l$
255 di=dcen(sbs$(l$,1,8))	 ! login date
258 do=dcen(sbs$(l$,20,8))	 ! logout date
260 if tt$<>sbs$(l$,52,4) then 500
262 if di<df then 500	
265 if di>dl then 500
280 ld=val(sbs$(xd$,4,2))
282 if ld=val(sbs$(l$,4,2)) then 320
285 if cd+ch+cm+cs=0 then 320
287 ! new day, set things up
288 xd$=sbs$(l$,1,8) : xx=dcen(xd$)
289 dw=xx-int(xx/7)*7
290 o3$="" : for jj=1 to 56 : o3$=o3$+o2$(jj) : next jj
291 print #4, sbs$(da$,dw*3+1,3);" ";xd$;" ";o3$;" ";
292 if cm>=10 then print #4, frmt$(cd,3);":";frmt$(ch,2);":";frmt$(cm,2)
293 if cm<10 then print #4, frmt$(cd,3);":";frmt$(ch,2);":0";frmt$(cm,1)
294 print #4,"             !   !   !   !   !   !   !   !   !   !   !   !   !   !   !"
296 for jj=1 to 56 : o2$(jj)=" " : next jj
297 ts=ts+cs : cs=0 : if ts>59 then  let ts=ts-60 : tm=tm+1
300 tm=tm+cm : cm=0 : if tm>59 then  let tm=tm-60 : th=th+1
305 th=th+ch : ch=0 : if th>23 then  let th=th-24 : td=td+1
310 td=td+cd : cd=0 : ld=val(sbs$(l$,23,2))
320 cp=val(sbs$(l$,10,2))*4+int(val(sbs$(l$,13,2))/15)-23
321 ct=val(sbs$(l$,43,2))*4+int(val(sbs$(l$,46,2))/15)
322 if cp<1 then  let cp=1 : else  if cp>56 then  let cp=56
323 if cp+ct>56 then  let ct=56-cp
324 for jj=cp to cp+ct : o2$(jj)="*" : next jj
325 cs=cs+val(sbs$(l$,49,2)) : if cs>59 then  let cs=cs-60 : cm=cm+1
330 cm=cm+val(sbs$(l$,46,2)) : if cm>59 then  let cm=cm-60 : ch=ch+1
335 ch=ch+val(sbs$(l$,43,2)) : if ch>23 then  let ch=ch-60 : cd=cd+1
340 cd=cd+val(sbs$(l$,39,3))
500 next i
510 o3$="" : for jj=1 to 56 : o3$=o3$+o2$(jj) : next jj
520 xx=dcen(xd$)
530 dw=xx-int(xx/7)*7
540 print #4, sbs$(da$,dw*3+1,3);" ";xd$;" ";o3$;" ";
550 if cm>9 then print #4, frmt$(cd,3);":";frmt$(ch,2);":";frmt$(cm,2)
552 if cm<=9 then print #4, frmt$(cd,3);":";frmt$(ch,2);":0";frmt$(cm,1)
560 for jj=1 to 56 : o2$(jj)=" " : next jj
570 ts=ts+cs : cs=0 : if ts>59 then  let ts=ts-60 : tm=tm+1
580 tm=tm+cm : cm=0 : if tm>59 then  let tm=tm-60 : th=th+1
590 th=th+ch : ch=0 : if th>23 then  let th=th-24 : td=td+1
600 td=td+cd : cd=0 : ld=val(sbs$(l$,23,2))
605 print #4, "--- -------- !   !   !   !   !   !   !   !   !   !   !   !   !   !   !"
607 print #4, "DAY DATE     6   7   8   9   10  11  12  13  14  15  16  17  18  19  20"
608 th=th+td*24
610 print #4
620 print #4, tab(58);"Total Connect :";frmt$(th,4);":";frmt$(tm,2) : print #4
630 close
635 print "Output is in file LOGYEAR.DOC"
640 exit
