C
C	The purpose of this routine is to get a unique 
C	Directory for each user.  This is done by the
C	INQUIRE statement in fortran.
C

	Subroutine GetDir(ptrInStack,DirStack,disk,type,class,ext)

	Parameter	screen=1

	Integer*2	ptrInStack
	Character*35	DirStack(1000)
	Character*35	temp
	Character*35	temp2
	Character*12	disk
	Character*12	type
	Character*12	class
	Character*7	ext
	Logical*1	exist
	Integer*2	box
	Character*1	letter
	Integer*2	idx
	Integer*2	idx2
	Integer*2	j

C	parse out the box number and the letter go to next odd
C	box number and if needed wrap on the letter or the box
	call str$upcase(ext,ext)
	letter=ext(1:1)
	read (unit=ext(2:7),fmt='(1I3)') box

C	Add 2 to the box and rebuild the extension
10	box=box+2
	if (box .ge. 1000) then
		box=1
		letter=char(ichar(letter)+1)
		if (letter .gt. 'Z') letter='A'
	end if
	ext(1:1)=letter
	write (unit=ext(2:4),fmt='(1I3)') box
	if (ext(2:2) .eq. ' ') ext(2:2)='0'
	if (ext(3:3) .eq. ' ') ext(3:3)='0'

	exist=.TRUE.
	temp='                                   '
	temp2='                                   '
	idx=1
	j=1
	Do while ((disk(j:j) .ne. ' ') .AND. (j	.le. len(disk)))
		j=j+1
	end do
	temp(idx:(idx+j-1))=disk(1:j-1)
	idx=idx+j-1

	temp(idx:(idx+1))=':['
	idx=idx+2

	j=1
	Do while ((type(j:j) .ne. ' ') .AND. (j	.le. len(type)))
		j=j+1
	end do
	temp(idx:(idx+j-1))=type(1:j-1)
	idx=idx+j-1

	temp(idx:idx)='.'
	idx=idx+1

	j=1
	Do while ((class(j:j) .ne. ' ') .AND. (j .le. len(class)))
		j=j+1
	end do
	temp(idx:(idx+j-1))=class(1:j-1)
	idx=idx+j-1

	temp2=temp
	idx2=idx
	temp(idx:idx)='.'
	idx=idx+1

	j=1
	Do while ((ext(j:j) .ne. ' ') .AND. (j	.le. len(ext)))
		j=j+1
	end do
	temp(idx:(idx+j-1))=ext(1:j-1)
	idx=idx+j-1

	temp(idx:idx)=']'
	idx=idx+1
	temp2(idx2:idx2)=']'
	idx2=idx2+1
C	add on the ext.DIR to the file
	temp2(idx2:idx+3)=ext
	idx2=idx2+4
	temp2(idx2:idx2+3)='.dir'
	idx2=idx2+4

C	Check to see if it exists
	inquire (file=temp2,exist=exist)
	if (exist) goto 10	!it already exists

	DirStack(ptrInStack+1)=temp

	end
