      SUBROUTINE rddata(string, iparse, iunit)
c		reads next data file package from a SF history file
c		created by XSPEC
c		fwj haberl march 1988
      INCLUDE '../inc/historysf.inc'
      INCLUDE '../inc/writebuf.inc'
      INCLUDE 'xplot.inc'
      CHARACTER*(*) string
      INTEGER*4 iunit, iparse
      INTEGER*4 infoar(4), nsubs, ierrsf, index, lenact, nstrd
      INTEGER*4 len, i, ndat, nret, iflag, idat
      CHARACTER*12 pkgtyp
      RECORD /his_data_files/datfil
      LOGICAL*4 qdone
 
      ndat = 1
      CALL xgtint(string, iparse, 1, 'no of data packages', 1, ndat,
     &            nret, iflag, -1)
      pkgtyp = 'data files'
      index = 0
      nsubs = 0
      len = len_his_data_files
      qdone = .FALSE.
      DO idat = 1, ndat
         IF (.NOT.qdone) THEN
            CALL nxpksf(iunit, pkgtyp, index, nsubs, infoar, datfil,
     &                  len, .TRUE., ierrsf)
            qdone = ierrsf.EQ.7
         ENDIF
      ENDDO
      IF (.NOT.qdone) THEN
         nstrd = 1
         DO i = 1, nsubs
            CALL rstrsf(iunit, datfil.charbuf, 1, nstrd, ierrsf)
            WRITE (wrtstr, '(a)') indent//datfil.fname
            CALL xwrite(wrtstr, 5)
         ENDDO
      ELSE
         WRITE (wrtstr, '(2a)') indent,
     &                       'No more data file package in history file'
         CALL xwrite(wrtstr, 5)
      ENDIF
      RETURN
      END
