      SUBROUTINE mkqdp(string, iparse, dset)
c		create QDP file for further analysis (fitting)
c		fwj haberl july 1988
      INCLUDE 'xplot.inc'
      INTEGER*4 dset, iparse, nret, iflg, idlm
      INTEGER*4 iset_m, iun, ierrsf, is, ise, i
      PARAMETER (iset_m=30)
      INTEGER*4 iset(iset_m)
      REAL*4 errx, erry
      CHARACTER*(*) string
      CHARACTER*64 fil
 
      IF (dset.EQ.0) THEN
         WRITE (*, '(a)') ' Nothing to write out yet'
         RETURN
      ENDIF
      CALL xgtstr(string, iparse, 1, 'file name', 1, fil, nret, iflg,
     &            idlm)
      CALL xtend(fil, 'qdp')
      CALL xgtint(string, iparse, iset_m, 'data sets', 1, iset, nret,
     &            iflg, idlm)
      CALL getlun(iun)
      CALL openwr(iun, fil, 'new', ' ', 'l', 256, 0, ierrsf)
      IF (ierrsf.NE.0) THEN
         WRITE(*,'(a)')'Unable to open file'
         RETURN
      ENDIF
      WRITE (iun, '(a)')' read serr 1 2'
      DO is = 1, nret
         ise = iset(is)
         DO i = nbins(ise), nbine(ise)
            errx = (errux(i)-errlx(i))*0.5
            erry = (erruy(i)-errly(i))*0.5
            WRITE (iun, '(4e16.8)') datax(i), errx, datay(i), erry
         ENDDO
      ENDDO
      CLOSE (iun)
      CALL frelun(iun)
      RETURN
      END
