      SUBROUTINE xrdqdp(string, iparse, dset, dset_new)
c	read data from QDP file
c       fwj haberl   13-JUN-1990 09:08:37
      INCLUDE 'xplot.inc'
      INTEGER*4 dset, dset_new, iparse
      INTEGER*4 ncom
      PARAMETER (ncom=5)
      CHARACTER*3 subcom(ncom)
      DATA subcom/'x', 'ex', 'y', 'ey', 'm'/
      INTEGER*4 icom(ncom)
      INTEGER*4 iun, ierrsf, i, ncolumn, nret, iflg, idlm, jcom, ibeg,
     &          iend
      INTEGER*4 iset, n_data, idata
      REAL*4 fdata(0:ncom)
      CHARACTER*(*) string
      CHARACTER*64 fil
      LOGICAL*4 qskip, qdone
 
      CALL xgtstr(string, iparse, 1, 'file name', 1, fil, nret, iflg,
     &            idlm)
      CALL xtend(fil, 'qdp')
      CALL getlun(iun)
      iflg = 0
      iset = dset + dset_new + 1
      n_data = nbine(dset+dset_new)
      nbins(iset) = n_data + 1
      DO i = 1, ncom
         icom(i) = 0
      ENDDO
      i = 0
      DO WHILE (iflg.EQ.0)
         CALL xgtarg(string, iparse, ibeg, iend, qskip, iflg, idlm)
         IF (iend.GE.ibeg) THEN
            i = i + 1
            CALL xmatch(string(ibeg:iend), subcom, ncom, jcom)
            icom(jcom) = i
         ENDIF
      ENDDO
      ncolumn = i
      OPEN (UNIT=iun, FILE=fil, STATUS='old')
      idata = 0
      qdone = .false.
      DO WHILE (.NOT.qdone)
         READ (iun, *, END=900) (fdata(i), i=1, ncolumn)
         idata = idata + 1
         n_data = n_data + 1
         datax(n_data) = fdata(icom(1))
         errlx(n_data) = datax(n_data) - fdata(icom(2))*0.5
         errux(n_data) = datax(n_data) + fdata(icom(2))*0.5
         datay(n_data) = fdata(icom(3))
         errly(n_data) = datay(n_data) - fdata(icom(4))*0.5
         erruy(n_data) = datay(n_data) + fdata(icom(4))*0.5
         modely(n_data) = fdata(icom(5))
      ENDDO
 900  CONTINUE
      CLOSE (iun)
      CALL frelun(iun)
      IF (idata.GT.0) THEN
         nbine(iset) = n_data
         dset_new = dset_new + 1
      ENDIF
      RETURN
      END
