10	 ! LOGCHECK.BAS
	 ! TO VERIFY CONSISTENCY AND ORDER OF ".LOG" FILES
	 ! WRITTEN BY BYEPDS (...BYE)
	 ! FOLLOWING CHECKS ARE PERFORMED:
	 ! 	1) DATES AND TIMES CAN BE INTERPRETED PROPERLY
	 ! 	2) LOGIN HAPPENS BEFORE LOGOUT
	 ! 	3) COMPUTED CONNECT TIME AGREES WITH LOGIN/LOGOUT TIMES
	 ! 	4) LOGOUT TIMES ARE IN ASCENDING ORDER
100 DIM L$[56](2),N$[50]V,A$[11]V
110 SD=24*3600	 ! SECONDS PER DAY
115 AN=1
120 CALL "SPAWNB"("SRD NA.DAT=/SE:*.LOG",AN)
125 OPEN #5,"NA.DAT"
127 INPUT LINE #5,A$
128 IF END #5 THEN 1100
130 INPUT LINE #5,A$
131 PRINT TAB(12);A$
210 N$=SBS$(A$,3)+".LOG/RN/RO/SH/LN:56":
	E=0 ! INITIALIZE ERROR COUNT
	T=0 ! INITIALIZE TOTAL CONNECT TIME
220 OPEN #3,N$:
	N=NRC(3):
	 IF N<6 THEN 1010
230 LF=0:
300 FOR I=6 TO N
310 INPUT LINE #3@I,L$(1)
320 ON ERROR GOTO 510
330	DI=DCEN(SBS$(L$(1),1,8))	 ! LOGIN DATE
	TI=SEC(SBS$(L$(1),10,8))	 ! LOGIN TIME
	DO=DCEN(SBS$(L$(1),20,8))	 ! LOGOUT DATE
	T0=SEC(SBS$(L$(1),29,8))	 ! LOGOUT TIME
	CT=SEC(SBS$(L$(1),43,8))	 ! PARTIAL CONNECT TIME
	CT=CT+SD*VAL(SBS$(L$(1),37,5))	 ! TOTAL CONNECT TIME
	 ON ERROR GOTO 0
340	 IF DI < 0
	 OR TI < 0
	 OR DO < 0
	 OR T0 < 0
	 OR CT < 0
	 THEN 510
350	 IF DI > DO
	 OR (DI=DO AND TI>T0)
	 THEN 530
360 IF SD*(DO-DI)+T0-TI <> CT THEN 550
380	 IF LF=1 THEN  IF 
	(DL > DO OR (DL=DO AND TL>T0))
	 THEN 570
390	DL=DO:
	TL=T0:
	L$(2)=L$(1):
	LF=1:
	T=T+CT
400 GOTO 1000
500	 ! ERROR MESSAGE SECTION
510	 PRINT "REC #";I;TAB(25);"FORMATTING ERROR":
	 PRINT L$(1):
	 ON ERROR GOTO 0:
	 GOTO 600
530	 PRINT "REC #";I;TAB(25);"LOGOUT BEFORE LOGIN":
	 PRINT L$(1):
	 GOTO 600
550	 PRINT "REC #";I;TAB(25);"CONNECT TIME WRONG":
	 PRINT L$(1):
	 PRINT "CT =";CT;", CALC =";(DO-DI)*SD+T0-TI:
	 GOTO 600
570	 PRINT "REC #";I;TAB(25);"RECORD OUT OF SEQUENCE":
	 PRINT L$(2) : PRINT L$(1):
	 GOTO 600
600	 PRINT :
	E=E+1:
	LF=0
1000 NEXT I
1010 PRINT TAB(40); "TOTAL ERRORS ON ";PIECE$(N$,"/",1);" =";E:
	 PRINT TAB(40); "TOTAL RECORDS =";NRC(3)-5:
	 PRINT TAB(40); "TOTAL CONNECT TIME = "STR$(INT(T/SD));":";TIM$(T-INT(T/SD)*SD)
1020 CLOSE 3
1030 GOTO 130
1100 CLOSE 
