	subroutine findpos(line,length,prevline,prevlen,offsetx,offsety)
	character*(*) line, prevline
	integer length, prevlen
	real  offsetx, offsety
c  find current position
c  expect position commands immediately before special string since first in box
c  NOTE: ASSUMES ABSOLUTE DOT POSITIONS (4 DIGITS)

	integer hatpos, temppos, position(2), poslen
	character*2 string, s(2)
	character posline*132
	data s/'^T','^J'/

	do i=1,2	! for x & y directions
c	    print *,' i=',i
	    string = s(i)
c  first check line for position commands
	    posline = line
	    poslen = length
	    checkingline = 1

c  loop comes here
50	    continue
c	    print *,' at 50 in findpos'
	    hatpos = 0

100	    continue
c	    print *,' at 100 in findpos'
c	    print *,'posline(hatpos+1:poslen)',posline(hatpos+1:poslen)
	    temppos = index(posline(hatpos+1:poslen),string)
	    if(temppos.gt.0) then	! found a position command
		hatpos = temppos + hatpos
		goto 100		! continue search
	    else	! no ^J left on line, see if one previously found
		if(hatpos.le.0) then	! none found
			if( checkingline.gt.1 ) then
				print *,'%QPOST-F-NOPOS No ',string,' found'
				call exit(0)
			endif
			posline = prevline
			poslen = prevlen
			checkingline = 2
			goto 50
		endif
c  previously found, extract position
		read(posline(hatpos+2:hatpos+5),'(i4)') position(i)
	    endif

	enddo	! for x & y directions

	offsetx = position(1)
	offsety = position(2)
c	print *,' in findpos: offsetx, offsety=', offsetx, offsety
	return
	end
