	Subroutine List_Sembud

	Parameter (screen=1,sembud=2,out=3,Rec_S=52)

	Logical*1	Exists
	Character*50	Out_Name
	Character*52	rec_line
	Character*24	Id_Key
	Character*12	Type
	Character*12	Sub_type
	Character*12	RecType
	Character*12	RecSub_type
	Character*12	disk
	Integer*2	group
	Integer*2	login_Q
	Integer*2	logout_Q
	Real*8		budget
	Integer*2	rate
	Integer*2	length
	Integer*2	length2
	Integer*2	IO_err

	Equivalence (rec_line(1:12),RecType)
	Equivalence (rec_line(13:24),RecSub_type)
	Equivalence (rec_line(25:36),disk)
	Equivalence (rec_line(37:38),group)
	Equivalence (rec_line(39:40),login_Q)
	Equivalence (rec_line(41:42),logout_Q)
	Equivalence (rec_line(43:44),rate)
	Equivalence (rec_line(45:52),budget)

	Inquire (File='MAKACT_FILES:sembud.idx',exist=Exists)
	If (Exists) then 
		Open (unit=sembud,file='MAKACT_FILES:sembud.idx',
     +		status='old',Organization='indexed',access='keyed',
     +		RecordType='fixed',form='unformatted',shared,
     +		key=(1:24,37:38),recordsize=Rec_S)
	else
		write (screen,*) '%%%%% No SemBud file'
		goto 9999
	end if

1	format (Q,A)

2	write (screen,3)
3	format (1x,'Output File Name    > ',$)
	read (screen,1,err=9999) length,Out_name
	if (length .eq. 0) goto 2

	Open (unit=out,file=Out_name,status='new',
     +	carriagecontrol='list',err=99)

5	type='            '
	Sub_type='            '
	length2=0
	write (screen,10)
10	format (/,' Input a blank line for entire listing on the TYPE',
     +		' or SUB-TYPE',/,1x,
     +		'Type of Account     > ',$)
	read (screen,1,err=9999) length,type
	if (length .eq. 0) goto 100

15	Sub_type='            '
	write (screen,20)
20	format (1x,'Sub-Type of Account > ',$)
	read (screen,1,err=5) length2,Sub_type

100	call str$upcase(type,type)
	call str$upcase(Sub_type,Sub_type)

	if ((type .eq. 'THSS ').OR.(type .eq. 'PROF ')) then
		if ((index(Sub_type,'_') .eq. 0).AND.
     +		    (length2 .ne. 0)) then
			Sub_type(length2+1:length2+1 )='_'
			length2=length2+1
		end if
	end if

	Id_Key=type//Sub_type

	if (length2 .ne. 0) then
		read (sembud,key=Id_Key,keyid=0,IOstat=IO_err) rec_line
	else
		read (sembud,keyge=Id_Key,keyid=0,IOstat=IO_err) rec_line
	end if

	if (IO_err .eq. 36) then
		write (screen,*) '%%%%% Warning NO records',
     +				 ' found for display'
		goto 15
	end if

	if ((IO_err .ne. 0).AND.(IO_err .ne. 36)) then
		write (screen,30)
30		format (1x,'%%%%% ERROR in the SemBud File')
		call Exit(IO_err)
	end if

	write (out,35)

	if (length2 .ne. 0) then 
		write (out,40) RecType,RecSub_type,disk,
     +		group,login_Q,logout_Q,rate,budget
		goto 15
	end if

	if (length .ne. 0) then
		call str$Upcase(type,type)
		Do While (type .eq. rec_line(1:12))
			write (out,40) RecType,RecSub_type,
     +			disk,group,login_Q,logout_Q,rate,budget
			read (sembud,err=300) rec_line
		end do
	else
200		write (out,40) RecType,RecSub_type,disk,
     +		group,login_Q,logout_Q,rate,budget
		read (sembud,err=5) rec_line
		goto 200
	end if

300	write (out,*) ' '
	write (screen,*) ' '
	goto 15

9999	close(sembud)
	close (out)
	goto 1000

99	close (out)
	write (screen,*) '%%%%% ERROR in opening ',Out_Name

35	format (/,'Type         Sub-Type     User Disk    UIC Grp',
     +		' Perm_Q  Over_q  Rate Budget',/,
     +		'------------ ------------ ------------ -------',
     +		' ------- ------- ---- ------------')
40	format (1A12,1x,1A12,1x,1A12,1x,1O7,2I8,1I5,1F13.2)

1000	end
