C
C	Author		: Patrick Feldner
C
C	Purpose		: The purpose of this program is to disuser all the
C			  accounts in a given file.
C
C

	Subroutine Disuser

	Character*60 file
	Character*132 line
	Integer      Count
	Integer      length
	Character*12 UserName
	Character*11 Uic
	Character*35 Directory
	Character*15 disk
	Logical*1    Confirm
	Character    Answer
	Integer      len
	Integer      error

	external lib$do_command

	Parameter ( screen=1,InFile=2 )

409	write (screen,410)
410	format (1x,'File    = ',$)
	read (screen,411,err=999) length,file
411	format (Q,A)
	if (length .eq. 0) goto 409

	Open (unit=InFile,file=file(1:length),readonly,
     +	status='old',form='formatted',carriagecontrol='list',
     +  err=490)

	Count=0
420	read (InFile,421,end=480) length,line
421	format (Q,A)
	Count=Count+1


	if (Parse(line,length,Directory,disk,Uic,Username) 
     +	    .ge. 1) goto 488

	if (Count .eq. 1) call OpenCom
	call WriteCom(Username)

	goto 420

480	call CloseCom
	close (InFile)
	write (screen,479)
479	format (1x,'%%%%% Batch Job Submitted')
	call lib$do_command
     +	('SUBMIT MAKACT_WORK:DISUSER.COM/NOPRINTER/QUEUE=MAKACT_Q')
	stop

488	if (Count .ne. 1) call CloseCom
	write (screen,489) file,Count
489	format (1x,'%%%%% ERROR in Processing File ',1A30,/,
     +	1x,'%%%%% On Line ',I5,/,
     +	1x,'%%%%% Batch Job NOT Submitted',/)
	close (InFile)
	stop

490	write (screen,491) file
491	format (1x,'%%%%% ERROR in Opening File Name ',1A30,/,
     +	'%%%%%% Or Associated Files')
	close (InFile)
	goto 409

999	end

C This is a routine to close all the open files used by remove
C it also writes out the closing statements for the .COM files.

	Subroutine CloseCom

	Parameter ( Disuser=3 )

C	Close the files
	write (Disuser,11)
11	format ('EXIT')
	write (Disuser,12)
12	format ('$ SET DEFAULT ''SAVE_DEFAULT''',/,'$ EXIT')
	close (Disuser)

	Return
	end

C This routine opens all the files and initializes them
C for their mission in life.

	Subroutine OpenCom

	Character*9 TheDate
	Character*8 TheTime

	Parameter ( Disuser=3 )

	Open (unit=Disuser,file='MAKACT_WORK:DISUSER.COM',
     +	status='new',form='formatted',carriagecontrol='list')

	Call Date(TheDate)
	Call Time(TheTime)

C	Init the Files
	write (Disuser,21) TheDate,TheTime
21	format ('$! Procedure generated to delete users from the system.'
     +	,/,'$! Generated on ',1A9,' at ',1A8,/,
     +	'$ SAVE_DEFAULT:=''F$LOGICAL("SYS$DISK")''''F$DIRECTORY()'' ')
	write (Disuser,23)
23	format ('$ SET DEFAULT SYS$SYSTEM',/,'$ SET UIC [1,4]',/,
     +  '$ RUN AUTHORIZE')

	Return
	end

C This routine writes out all the information to the individual files
C such as the disk name to the RemQuo file.
	Subroutine WriteCom(Username)

	Character*12 Username

	Parameter ( Disuser=3 )

	write (Disuser,3) Username
3	format ('MODIFY ',1A12,'/FLAGS=DISUSER')

	Return
	end
