cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cc                     Version 1.1                        cc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      subroutine export
      include 'penplot.com'
      character*80 lines(50)
      open(unit=1,file='plot.var',status='old')
      
      nlines=1
 100  read(1,1,end=200)lines(nlines)
 1    format(a)
      nlines=nlines+1
      goto 100

 200  nlines=nlines-1
      rewind(1)
      
      do 10 i=1,nlines
         if(lines(i)(1:5).eq.'xmin=')then
            call repl(lines(i),x0,5)
         elseif(lines(i)(1:5).eq.'xmax=')then
            call repl(lines(i),x1,5)
         elseif(lines(i)(1:5).eq.'ymin=')then
            call repl(lines(i),y0,5)
         elseif(lines(i)(1:5).eq.'ymax=')then
            call repl(lines(i),y1,5)
         elseif(lines(i)(1:6).eq.'xvmin=')then
            call repl(lines(i),xv0,6)
         elseif(lines(i)(1:6).eq.'xvmax=')then
            call repl(lines(i),xv1,6)
         elseif(lines(i)(1:6).eq.'yvmin=')then
            call repl(lines(i),yv0,6)
         elseif(lines(i)(1:6).eq.'yvmax=')then
            call repl(lines(i),yv1,6)
         endif
         write(1,1)lines(i)(1:lnblnk(lines(i)))
 10   continue
      endfile(unit=1)
      close(unit=1)
      return
      end

      subroutine repl(ln,v,j)
      character*80 ln,temp,temp1
      real v

c      write(*,*)ln
      write(temp,*)v
 10   if(temp(1:1).ne.' ')goto 11
      temp=temp(2:80)
      goto 10
 11   continue

      k=index(ln,'#')
      if(k.eq.0)then
         ln(j+1:80)=temp
      else
         temp1=ln(k:80)
         ln(j+1:80)=temp
         if(ln(k:k).eq.' ')then
            ln(k:80)=temp1
         else
            ln=ln(1:lnblnk(ln))//' '//temp1
         endif
      endif
c      write(*,*)ln
      return
      end
