10	 ! LOGTOT.BAS
	 ! TO TOTAL LOGGED ON TIME FOR A GIVEN PERIOD
	 ! THIS VERSION DOES A BAR GRAPH OUTPUT
	 ! FOR all terminals
100 DIM L$[56],N$[50]V,D1$[9],D2$[9],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, "LOGBAR.DOC/WR"
125 set upper on
130 input "User Name ";n$
150 set upper off
200 print #4,"                                                          User Name ";N$
201 print #4, "                                                         All Terminals"
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 "MONTH,YEAR TO PLOT ";MO,YR
211 D1$="01-"+SBS$(MO$,3*MO-2,3)+"-"+FRMT$(YR,2) : DF=DCEN(D1$)
212 IF DF<1 THEN PRINT "INVALID DATE, " : GOTO 210
213 PRINT #4,"                                                      STARTING DATE ";D1$
214 MO=MO+1 : IF MO=13 THEN LET YR=YR+1 : MO=1
215 D2$="01-"+SBS$(MO$,3*MO-2,3)+"-"+FRMT$(YR,2) : DL=DCEN(D2$)-1 : D2$=DDAT$(DL)
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:
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
265 IF DI<DF THEN 500	
270 IF DI>DL THEN 500	
275 IF XD$="" THEN LET XD$=SBS$(L$,1,8) : LD=VAL(SBS$(XD$,4,2))
280 IF LD=VAL(SBS$(L$,23,2)) THEN 320
285 IF CD+CH+CM+CS=0 THEN 320
287 ! NEW DAY, SET THINGS UP
288 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,"             !   !   !   !   !   !   !   !   !   !   !   !   !   !   !"
295 XD$=SBS$(L$,1,8)
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 LOGBAR.DOC"
640 EXIT
