1 '	signon subsystem -- finish (update user's record)
2 MODNAME$="FINISH"
4 VERSION$="1.4 {10/14/82}"	'not in 1.0
7 '	by dick lieber
13 '
28 '
49 PWDFILE$="pwds"	'subsystem configuration file
50 COMMENTFILE$="COMMENTS"
52 CALLERFILE$="CALLERS" 'log of users
55 USERFILE$="USERS"	'roster of users
56 LASTCALRFILE$="LASTCALR"
80 '
81 '	function definition
82 '
83 '	add deliminators to time or date
84 DEF FNADDSEP$(DS$,DELIM$)=

	LEFT$(DS$,2)+DELIM$+MID$(DS$,3,2)+DELIM$+RIGHT$(DS$,2)
85 '	remove date or time deliminators
86 DEF FNKILLSEP$(DS$)=LEFT$(DS$,2)+MID$(DS$,4,2)+RIGHT$(DS$,2)
88 DEF FNHOURS$(TIME)=STR$(INT(TIME/60))+":"+

	RIGHT$("00"+MID$(STR$(TIME-(INT(TIME/60)*60)),2),2)
90 DEF FNEROR$(SERRNUMB$)="System Error ("+SERRNUMB$+")."
94 '	constants:
96 CRLF$=CHR$(&HD)+CHR$(&HA)
97 BSTRING$=CHR$(8)+" "+CHR$(8)
98 DEFDRIVE$="A:"
99 DIM ACLARRAY%(5,11)
100 DIM FLAGS%(14)
103 '
106 '
109 '
112 ON ERROR GOTO 1000
115 GOTO 10000	' main program begins after sub routines
118 '
121 ' routines used by signon
124 '
200 %INCLUDE 200.SSB
300 '
302 '	set user number
304 '
306 USERMD=TESTADDRESS+9
312 CALL USERMD(SETUSERNUMBER%)
345 RETURN
1000 '
1004 '	Error handler
1008 '1.1
1010 IF ERR=53 THEN NOFILE%=1: RESUME NEXT
1012 PRINT "Error Trap"
1020 PRINT "ERR = ";ERR, "ERL = ";ERL
1028 END
1100 %INCLUDE 1100.SSB
1200 '
1204 ' find name - get record
1208 ' 1.3
1211 SETUSERNUMBER%=USERNUMBER%: GOSUB 300
1212 NOTFOUND%=0
1216 REC%=2
1220 LAST$=SPACE$(14): FIRST$=RIGHT$(LAST$,10)
1224 LSET FIRST$=FRNAME$: LSET LAST$=LNAME$
1228	GET #1,REC%
1232	IF EOF(1) THEN NOTFOUND%=1:RETURN
1236	IF FFNAME$=FIRST$ AND FLNAME$=LAST$ THEN GOSUB 1300: RETURN
1240	REC%=REC%+1
1244 GOTO 1228
1300 %INCLUDE 1300.SSB
1400 %INCLUDE 1400.SSB
1600 %INCLUDE 1600.SSB
1900 '
1905 '	get date into sdate$ (sdate$ looks nice to print)
1910 '
1915 SDATE$=LEFT$(LDATE$,2)+"/"+MID$(LDATE$,3,2)+"/"+RIGHT$(LDATE$,2)
1920 RETURN
2300 %INCLUDE 2300.SSB
3100 %INCLUDE 3100.SSB
3200 '
3205 '	turn off status line
3206 ' 1.1
3210 A$=STATQUIT$ : GOSUB 3100
3215 RETURN
8000 %INCLUDE 8000.SSB
8500 '
8510 '	put information into CALLERFILE$
8520 '
8530 GET #3, NEXTRECORD
8540 LSET CTIMEON$ = STR$(ELAPTIME%)
8550 PUT #3, NEXTRECORD
8560 GET #3,1	'just to flush buffer
8570 CLOSE #3
8580 RETURN
8600 '
8605 '	open CALLERFILE$
8610 ' 1.0
8611 NOFILE%=0
8615 SETUSERNUMBER%=USERNUMBER%: GOSUB 300
8620 OPEN "R",#3, DEFDRIVE$+CALLERFILE$, 75
8625 FIELD #3,

	8  AS CLOGCNT$,

	6  AS FCALDATE$,

	6  AS FCALTIME$,

	1  AS SIGNATURE$,

	8  AS CLREC$
8630 GET #3,1
8635 IF SIGNATURE$<>"*" THEN

	CLOSE #3:

	NOFILE%=1:

	COMMENT$=A$:GOSUB 8000:

	KILL DEFDRIVE$+CALLERFILE$:

	RETURN
8640 LOGCNT#=VAL(CLOGCNT$)
8645 NEXTRECORD = VAL(CLREC$)
8650 IF NOFIELD%<>0 THEN NOFIELD%=0: RETURN
8655 FIELD #3, 20 AS CFNAME$,

		20 AS CLNAME$,

		6  AS CDATE$,

		6  AS CTIME$,

		6  AS CTIMEON$,

		10 AS CNOTATION$,

		2  AS CCRLF$
8660 RETURN
9000 '
9005 '	get lastcal info
9010 '1.3	#
9012 SETUSERNUMBER%=0: GOSUB 300
9013 NOFILE%=0
9015 OPEN "I", #1, DEFDRIVE$+LASTCALRFILE$
9017 IF NOFILE%<>0 THEN

	CLOSE #1:

	COMMENT$="LASTCALR file not found":

	PRINT COMMENT$:

	GOSUB 8000: RETURN
9025 INPUT #1, FRNAME$, LNAME$, ACLVL%, LDATE$, LTIME$
9035 CLOSE #1
9045 RETURN
9100 %INCLUDE 9100.SSB
9900 '
9903 '	select default disk
9906 '	1.0	#
9909 SELDSK=TESTADDRESS+&HF
9912 CALL SELDSK(SELDRIVE%)
9915 RETURN
10000 '
10010 '	main program
10020 '1.11
10030 PRINT "FINISH version ";VERSION$;" is updating user's records."
10040 GOSUB 1100	'get configuration data
10050 IF NOFILE%<>0 THEN SETUSERNUMBER%=0: GOSUB 300: GOTO 10000
10060 NOTATION$="finish"
10070 GOSUB 9000	'get user
10080 IF NOFILE%<>0 THEN GOTO 10330
10085 IF LEFT$(FRNAME$,1)="~" THEN

	PRINT "Records previously updated.":

	GOTO 10330
10090 GOSUB 1600	'get time/date
10093 STIME$=TIME$
10100 GOSUB 9100	'calc elapsed time
10110 ' 	put information into users record
10120 GOSUB 1400	'open users
10130 GOSUB 1200	'search for users record
10140 IF NOTFOUND% <>0 THEN

	COMMENT$="Couldn't find "+FRNAME$+" "+LNAME$+"'s records.":

	PRINT COMMENT$:

	GOSUB 8000
10150 GOSUB 1300	'transfer to working vars
10160 ELAPTIME%=ELAPMINUTES
10180 TOTALTIME = TOTALTIME + ELAPMINUTES
10190 GOSUB 200		'put & close users records
10200 '	put information into CALLERFILE$
10210 GOSUB 8600	'open CALLERFILE$
10220 IF NOFILE%=0 THEN GOSUB 8500	'only update if file exists
10225 SETUSERNUMBER%=0: GOSUB 300
10227 SELDRIVE%=0: GOSUB 9900
10230 FCBNAME$ = LASTCALRFILE$
10240 RO%=0: GOSUB 2300
10250 OPEN "O", #1, DEFDRIVE$ + LASTCALRFILE$
10251	PRINT  #1, "~"; ",";

		"already"; ","; "updated"; ",";

		0; ",";"xxxxxxxx"; ","; "xxxxxxxx"
10252 CLOSE #1
10253 RO%=1: GOSUB 2300
10290 SETUSERNUMBER%=0: GOSUB 300
10310 PRINT "Records for ";FRNAME$;" ";LNAME$;" updated."
10320 PRINT "Signed off at ";FNADDSEP$(TIME$,":");

	" after";FNHOURS$(ELAPMINUTES);" (hr:mn)"
10322 IF STATUSLINE%<>0 THEN GOSUB 3200
10325 '	end processing
10330 PRINT: PRINT "Loading BYE..."
10340 NOFILE%=0
10350 RUN DEFDRIVE$+BYEPROG$
10360 IF NOFILE%<>0 THEN

	COMMENT$="Couldn't find "+DEFDRIVE$+BYEPROG$+".COM":

	PRINT COMMENT$:

	GOSUB 8000
10400 SETUSERNUMBER%=0: GOSUB 300
10420 POKE 4,0
20000 '
