	Subroutine Last_Login_Check

	External SS$_Normal

	Character*1412	Rec_line
	Integer*4	Sys$AscTim
	Integer*4	status
	Integer*4	Last_log(2)
	Character*23	Today
	Character*23	Date_Time
	Integer*2	year
	Integer*2	month
	Integer*2	day
	Integer*2	yyyy
	Integer*2	mmmm
	Integer*2	dddd
	Character*48	Month_lst
	Integer*2	result
	Integer*2	limit
	Character*10	In_Limit
	Character*20	Username
	Character*40	filename
	Integer*4	cvtflg
	Integer*2	count

	Parameter	(screen=1,No_Record='182B2'X)
	Parameter	(Last_Login_I='18C'X+1,Uaf=3)
	Parameter	(User_Pos='4'X+1)

	Equivalence (Rec_line(Last_Login_I:Last_Login_I+8),Last_Log)
	Equivalence (Rec_line(User_Pos:User_Pos+20),Username)

	count=0

	Month_lst='JAN-FEB-MAR-APR-MAY-JUN-JUL-AUG-'//
     +		  'SEP-OCT-NOV-DEC-'

	cvtflg=0
	status=Sys$AscTim(,Today,,%VAL(cvtflg))
	if (status .ne. %LOC(SS$_Normal)) then
		write (screen,*) '%%%%% ERROR in the Time Conv.'
		call Exit(status)
	end if

	read (unit=Today(8:11),fmt='(1I4)') year
	read (unit=Today(1:2),fmt='(1I2)') day
	month=((index(Month_lst,Today(4:7))-1)/4)+1

3	write (screen,1)
1	format (1x,'Un-Used Time limit in Months [6] > ',$)
	read (screen,2,err=999) length,In_limit
2	format (Q,A)
	if (length .eq. 0) then
		limit=6
		goto 40
	end if
	read (unit=In_Limit(1:length),fmt='(1I5)',err=3) limit

40	Open(	unit=Uaf, File='sys$system:sysuaf.dat', readonly,
     +		status='old', shared, organization='indexed',
     +		access='keyed', recordtype='variable',
     +		form='unformatted')

	Read(Uaf, keyGE='            ', IOstat=IO_err) Rec_line

	if ((IO_err .gt. 0).AND.(IO_err .ne. 67)) then 
		close (Uaf)	
		write (screen,100)	
100		format (1x,'%%%%% Problem with the UAF access !!!')
		call exit(IO_err)
	end if

10	status=Sys$AscTim(,Date_Time,Last_Log,%VAL(cvtflg))
	if (status .ne. %LOC(SS$_Normal)) then
		write (screen,*) '%%%%% ERROR in the Time Conv.'
		call Exit(status)
	end if

	read (unit=Date_Time(8:11),fmt='(1I4)') yyyy
	read (unit=Date_Time(1:2),fmt='(1I2)') dddd
	mmmm=((index(Month_lst,Date_Time(4:7))-1)/4)+1

	result=((year-yyyy)*12+month)-mmmm

	if (result .ge. limit) then
		if (count .eq. 0) then 
			write (screen,50)
50			format (' Username            ',5x,
     +				'Last Login Date        ',/,
     +				  '--------------------',5x,
     +				'-----------------------')
			count=count+1
		end if
		if (yyyy .ne. 1858) then
			write (screen,60) Username,Date_Time
60			format (1x,1A20,5x,1A23)
		else
			write (screen,70) Username
70			format (1x,1A20,5x,'Not Used Since Update')
		end if
	end if

	read(Uaf,err=10,end=999) Rec_line
	goto 10

998	write (screen,*) '%%%%% ERROR in opening ',filename
999	end

C
C
	Subroutine Last_Login_File

	External SS$_Normal

	Character*1412	Rec_line
	Integer*4	Sys$AscTim
	Integer*4	status
	Integer*4	Last_log(2)
	Character*23	Today
	Character*23	Date_Time
	Integer*2	year
	Integer*2	month
	Integer*2	day
	Integer*2	yyyy
	Integer*2	mmmm
	Integer*2	dddd
	Character*48	Month_lst
	Integer*2	result
	Integer*2	limit
	Character*10	In_Limit
	Character*20	Username
	Character*40	filename
	Integer*4	cvtflg
	Integer*2	count

	Parameter	(out=6)
	Parameter	(screen=1,No_Record='182B2'X)
	Parameter	(Last_Login_I='18C'X+1,Uaf=3)
	Parameter	(User_Pos='4'X+1)

	Equivalence (Rec_line(Last_Login_I:Last_Login_I+8),Last_Log)
	Equivalence (Rec_line(User_Pos:User_Pos+20),Username)

	count=0

	Month_lst='JAN-FEB-MAR-APR-MAY-JUN-JUL-AUG-'//
     +		  'SEP-OCT-NOV-DEC-'

	cvtflg=0
	status=Sys$AscTim(,Today,,%VAL(cvtflg))
	if (status .ne. %LOC(SS$_Normal)) then
		write (screen,*) '%%%%% ERROR in the Time Conv.'
		call Exit(status)
	end if

	read (unit=Today(8:11),fmt='(1I4)') year
	read (unit=Today(1:2),fmt='(1I2)') day
	month=((index(Month_lst,Today(4:7))-1)/4)+1

14	write (screen,15)
15	format (1x,'Output Filename                  > ',$)
	read (screen,2,err=999) length,filename
	if (length .eq. 0) goto 14

3	write (screen,1)
1	format (1x,'Un-Used Time limit in Months [6] > ',$)
	read (screen,2,err=14) length,In_limit
2	format (Q,A)
	if (length .eq. 0) then
		limit=6
		goto 40
	end if
	read (unit=In_Limit(1:length),fmt='(1I5)',err=3) limit

40	Open(unit=out,file=filename,status='new',err=998,
     +	carriagecontrol='list')
	Open(	unit=Uaf, File='sys$system:sysuaf.dat', readonly,
     +		status='old', shared, organization='indexed',
     +		access='keyed', recordtype='variable',
     +		form='unformatted')

	Read(Uaf, keyGE='            ', IOstat=IO_err) Rec_line

	if ((IO_err .gt. 0).AND.(IO_err .ne. 67)) then 
		close (Uaf)	
		write (screen,100)	
100		format (1x,'%%%%% Problem with the UAF access !!!')
		call exit(IO_err)
	end if

10	status=Sys$AscTim(,Date_Time,Last_Log,%VAL(cvtflg))
	if (status .ne. %LOC(SS$_Normal)) then
		write (screen,*) '%%%%% ERROR in the Time Conv.'
		call Exit(status)
	end if

	read (unit=Date_Time(8:11),fmt='(1I4)') yyyy
	read (unit=Date_Time(1:2),fmt='(1I2)') dddd
	mmmm=((index(Month_lst,Date_Time(4:7))-1)/4)+1

	result=((year-yyyy)*12+month)-mmmm

	if (result .ge. limit) then
		if (count .eq. 0) then 
			write (out,50)
50			format ('Username            ',5x,
     +				'Last Login Date        ',/,
     +				  '--------------------',5x,
     +				'-----------------------')
			count=count+1
		end if
		if (yyyy .ne. 1858) then
			write (out,60) Username,Date_Time
60			format (1A20,5x,1A23)
		else
			write (out,70) Username
70			format (1A20,5x,'Not Used Since Update')
		end if
	end if

	read(Uaf,err=10,end=999) Rec_line
	goto 10

998	write (screen,*) '%%%%% ERROR in opening ',filename
999	end

C
C	This is the routine to remove those accounts found by
C	the OLD LOGIN command.
C
	Subroutine Last_Login_Remove

	Parameter (screen=1,in=2)

	External Lib$Do_Command

	Logical*1	GetInfo
	Character*35	dir
	Character*15	disk
	Character*12	user
	Character*12	uic
	Integer*2	length
	Integer*2	count
	Logical*1	In_Progress
	Character*40	inName
	Character*80	line
	Integer*2	count_line
	Integer*2	temp

C	Check to see if a REMALL is in Progress
	inquire (file='MAKACT_WORK:REMOVE_IN_PROGRESS.TEMP',
     +	exist=In_Progress)
	if (In_Progress) then
		write (screen,131)
131		format (1x,'%%%%% REMALL Currently in the',
     +		' Batch Queue.',/,1x,'%%%%% REMOVE NOT permitted')
		goto 12000
	end if

132	write (screen,133)
133	format (1x,'Input File name > ',$)
	read (screen,2,err=12000) length,inName
2	format (Q,A)
	if (length .eq. 0) goto 132

	Open (unit=in,file=inName,status='OLD',
     +	carriagecontrol='list',err=998)

	count=0
	count_line=0
	call OpenAll

10	line='                                        '//
     +	     '                                        '
	read (in,12,err=999) line
12	format (1A80)
	count_line=count_line+1
	user=line(1:12)

	read (unit=line(26:27),fmt='(1I2)',err=44) temp
	goto 47
44	if (line(26:28) .ne. 'Not') goto 10

47	if (GetInfo(user,uic,dir,disk)) then
		call WriteAll(dir,disk,uic,user)
		count=count+1
		else
		write (screen,30) user,count_line
30		format (1x,'%%%%% Error in finding user ',1A12,
     +			' on line ',1I5,/,
     +			1x,'%%%%% Batch ABORTED')
		call CloseAll
		call Exit
	end if

	goto 10

999	call CloseAll
	if (count .ge. 1) then
		write (screen,1000)
1000		format (1x,'%%%%% Batch Job Submitted')
		call Lib$Do_Command ('@MAKACT_WORK:REMALL.COM')
	end if
	goto 12000

998	write (screen,*) '%%%%% ERROR in opening ',InName
	goto 132

12000	end
