cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cc                     Version 1.1                        cc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

cccccccccccccc
c
c   calls:
c      call setdash(pattern)
c         character*16 pattern
c             sets pattern for dashed lines  '-' = filled in ' ' or '.'
c             = empty
c         e.g. '--------....--..' to produce dash-dot pattern
c
c      call dash(x,y)
c         like plot, except uses dash pattern
c
c     call dashup
c         like penup
c
ccccccccccccccc
c
c      character*16 dashpat
c      call window(0.,0.,1.,1.)
c 10   call vtmode
c      write(*,*)'dashpat>'
c      read(*,'(a16)')dashpat
c      call gmode
c      call erase
c      call setdash(dashpat)
c      do i=0,5
c         x=0.2*i
c         y=x*x
c         call dash(x,y)
c         enddo
c      call penup
c      call tsend
c      goto 10
c      end
c

      subroutine setdash(dashin)
      character*(*) dashin
      character*16 dashpat
      character*1 mode
      common/pendash/dashpat,mpat,aleft,aleft0,mode
      include 'penplot.com'
      dashpat=dashin
      if (dashpat.eq.'----------------')then
         mpat=0
      else
         mpat=-1
         aleft0=0.5*(xv1-xv0)/100.0
         endif
      call penup
      return
      end

      subroutine dashup
      character*16 dashpat
      character*1 mode
      common/pendash/dashpat,mpat,aleft,aleft0,mode
        if (mpat.gt.0)mpat= -1
        call penup
        return
        end

      subroutine dash(x,y)
      character*16 dashpat
      character*1 mode
      common/pendash/dashpat,mpat,aleft,aleft0,mode
      include 'penplot.com'
        xp=ax*x+bx
        yp=ay*y+by
        if(xp.lt.xv0 .or. xp.gt.xv1 .or. yp.lt.yv0 .or. yp.gt.yv1)then
           call dashup
           return
           endif
        if(mpat.eq.0)then
           call plot(x,y)
           return
        endif
        if(mpat.lt.0)then
           mpat=1
           aleft=aleft0
           mode=dashpat(1:1)
           xfin=x
           yfin=y
           call plot(x,y)
           dxf=(xv1-xv0)/(x1-x0)
           dyf=(yv1-yv0)/(y1-y0)*780.0/1024.0
           return
           endif
        dx=x-xfin
        dy=y-yfin
        d=sqrt( (dx*dxf)**2 + (dy*dyf)**2)
        if(d.gt.0.0)delfac=aleft0/d
 10     if(d.gt.aleft)then
           xfin=xfin+delfac*aleft/aleft0*dx
           yfin=yfin+delfac*aleft/aleft0*dy
           d=d-aleft
           mpat=mpat+1
           if(mpat.gt.16)mpat=1
           if(dashpat(mpat:mpat).ne.mode)then
              if(mode.eq.'-')then
                 call plot(xfin,yfin)
                 call penup
              else
                 call plot(xfin,yfin)
              endif
           endif
           mode=dashpat(mpat:mpat)
           aleft=aleft0
        else
           xfin=x
           yfin=y
           aleft=aleft-d
           if(mode.eq.'-')call plot(xfin,yfin)
           d=0
        endif
        if(d.gt.0)goto 10
        return
        end

