c-----------------------------------------------------------------------
      subroutine limits(str, first, last)
c-----------------------------------------------------------------------
c     
c     This subroutine finds the "FIRST" and the "LAST" non-blank
c     characters in the string "STR". The length of the string is not 
c     numerically  limited, but its length is determined when called.
c     "I" and "IB" are the forward and backward counters. 
c
      character str*(*)
      integer first, last, i, ib
c
      first = 0
      last = 0
      do i = 1, len(str)
         if (first .eq. 0) then
            if (str(i:i) .ne. ' ') first = i
         end if
c
         if (last .eq. 0) then
            ib = (len(str) - i) + 1
            if (str(ib:ib) .ne. ' ') last = ib
         end if
      end do
      return 
      end
