	.TITLE	ByeSub
	.Ident	/Ver 01/

;+
;
; *** ByeSub -- subroutine for "Bye" utility to erase user's
;		last name in "MAILLOG.Dat",indexed by terminal number
;
;	Written By:
;
;		Michael Lynch
;		Engineering Systems and Technology Labs
;		3M Co.
;		3M Center
;		St. Paul, Mn. 55144
;
;		Note: if some other user is accessing MAILLOG.DAT,
;			we would fail to open that file. Therefore,
;			we try to re-open the file 3 additional times.
;
;-

	.MCALL	FDOF$L,FCSBT$S,FDBDF$,FDAT$A,FDRC$A,FDOP$A,FDBF$A,FSRSZ$
	.MCALL	CLOSE$,PUT$R,Open$U,GLUN$S,FINIT$,Mrkt$S,Wtse$S

LogSiz=14.			;size of last name in account file
Retry:	.word	3		;3 retrys to open file (4 trys altogether)
LunBuf:	.BlkW	6.

$UsrSb::			;reference label expected by Bye

	GLUN$S	#1,#LunBuf	;get ti: info
	Clr	R1		;set up record pointer
	BisB	LunBuf+2,R1	;get unit number
	Inc	R1		;TT0: is the 1st record
	Br	20$		;go and open file

10$:	Dec	Retry			;are we through trying ?
	Beq	30$			;if so, exit
	Mrkt$s	#FilEfn,#60.,#1		;time for 1 second
	Wtse$s	#FilEfn			;wait for timer to complete
20$:	Open$U	#LogFDB			;open log file for update
	Bcs	10$			;if error, jump around
	Put$R	#LogFDB,#Blank,#logSiz,R1,#0	;make up new record
	Close$				;close the file

30$:	Return

	.PAGE
	.SBTTL	File I/O Macros and processing

 
	FilLun = 2			;use account file lun
	FilEfn = 1			;use account file Event Flag
 
	FDOF$L				;DEFINE FDB OFFSETS
	FCSBT$S				;DEFINE FDB BIT PARAMETERS
LogFDB:	FDBDF$				;DEFINE FDB FOR Log file
	FDAT$A	R.fix,,LogSiz		;define type and size of records
	FDRC$A	FD.ran,Blank,LogSiz	;BUFFER LOCATION,LENGTH
					;MOVE MODE SPECIFIED BY DEFAULT
	FDOP$A	FilLun,DatDsc,,,fa.dlk
	FDBF$A	FilEfn			;FCS EVENT FLAG FOR THIS FILE
	Fsrsz$	1			;ask for buffer
	FInit$

DATDSC:	.WORD	DEVSIZ,DEVNAM		;DEVICE NAME DESCRIPTOR
	.WORD	DIRSIZ,DIRNAM		;UIC DESCRIPTOR
	.WORD	FILSIZ,FILNAM		;FILE NAME DESCRIPTOR
 
DEVNAM:	.ASCII	"DM1:"
DEVSIZ=	.-DEVNAM
DIRNAM:	.ASCII	"[010,003]"
DIRSIZ=.-DIRNAM
 
FILNAM:	.ASCII	"MAILLOG.DAT"
FILSIZ=.-FILNAM
 
Blank:	.Rept	LogSiz
	.byte	0
	.EndR
	.even

	.End
