      SUBROUTINE CAPLOT(X,Y,IND)
* CALCOMP MODEL M84 PLOTTING ROUTINE   
      INCLUDE 'SIZES'
      COMMON/ OUTPUT/ IPAPER,IPAGE
      CHARACTER*80  FILEIN, FILOUT, FILPLT, LLEGND
      CHARACTER*1 ASCII, ESC
      COMMON /ASCIIC/ ASCII(0: 255)
      COMMON /LEGEND/  FILEIN, FILOUT, FILPLT, LLEGND
      INTEGER PIXROW, PIXCOL, PIXEL
      COMMON /TERM/ IMAXR, IMAXC, PIXROW, PIXCOL, PIXEL, LCOUNT, INGRAF,
     .              IXL, IXR, IYT, IYB, NCOLOR, MCOLOR( 64 ), ITTRM,
     .              MARGX, MARGY
* VARIABLES IN COMMON TERM:
*  IMAXR = MAX NUMBER OF ROWS
*  IMAXC = MAX NUMBER OF COLUMNS
*  PIXROW = NUMBER OF PIXELS PER ROW
*  PIXCOL = NUMBER OF PIXELS PER COLUMN
*  PIXEL  = LESSER OF PIXROW OR PIXCOL
*  LCOUNT = NUMBER OF LINES CURRENTLY WRITTEN TO DIALOG AREA
*  INGRAF = 0=> HOST TEXT GOES TO MONITOR SPACE\\ 1=> TEXT TO GRAPHICS
*  IXL    = LEFT MOST VALUE OF X
*  IXR    = RIGHT MOST VALUE OF X
*  IYT    = VALUE OF Y AT TOP OF SCREEN
*  IYB    = VALUE OF Y AT BOTTOM OF SCREEN
*  NCOLOR = NUMBER OF COLORS IN MCOLOR MAP
*  MCOLOR = MAP OF COLORS
*  ITTRM  = UNIQUE MODEL NUMBER OF GENERAL TERMINAL TYPE
*  MARGX  = NUMBER OF PIXELS PADDED TO X-COORDINATE
*  MARGY  = NUMBER OF PIXELS PADDED TO Y-COORDINATE
*
*
      EQUIVALENCE (ESC, ASCII(27))
C
C   CODES FOR IND:
C
C     IND = 0   =>  REMOVE ALL GRAPHICS TO QUIT
C     IND = 1   =>  ANY ONE TIME ONLY INITIALIZATION
C     IND = 2   =>  MOVE GRAPHICS TO POINT (X,Y) -- DO NOT DRAW LINE
C     IND = 3   =>  DRAW LINE FROM LAST POINT TO NEW (X,Y)
C     IND = 4   =>  DRAW DARK LINE
C     IND = 5   =>  DRAW BRIGHT SOLID LINE
C     IND = 6   =>  INITIALIZE & SET-UP FOR NEXT PICTURE
C     IND = 8   =>  TEMPORARY RELEASE FROM GRAPHICS
C     IND = 9   =>  RETURN TO GRAPHICS FROM TEMP RELEASE
C
*     IND = 99  =>  SET NEW COLOR (VALUE IN X)
*
C
      IF (IND.EQ.0) THEN
C  ALL DONE -- CLEAR TERMINAL AND WE WILL QUIT
         WRITE ( 11, '('' H;F0;'')' ) 

      ELSEIF (IND.EQ.1) THEN
C  ONE TIME ONLY INITIALIZATION OF TERMINAL
         PIXEL = 2000. * IPAPER / 100.
         NCOLOR = 8

      ELSEIF (IND.EQ.2 ) THEN
* MOVE TO POINT WITHOUT DRAWING LINE
* THIS DEVICE CLIPS FOR ME
         IXLX = X * PIXEL
         IYLY = Y * PIXEL
         WRITE ( 11, '('' H;C'', I5, '','', I5,'';K;'')') IXLX, IYLY

      ELSEIF (IND .EQ. 3) THEN
C DRAW LINE FROM LAST POINT TO NEW POINT
*   THIS DEVICE CLIPS FOR ME
         IXLX = X * PIXEL
         IYLY = Y * PIXEL
         WRITE ( 11, '('' I;C'', I5, '','', I5,'';K;''))') IXLX, IYLY

      ELSEIF (IND.EQ.4) THEN
* NO ABILITY TO ERASE FIGURE FOR PEN PLOTTER

      ELSEIF (IND.EQ.5) THEN
* NO ABILITY TO ERASE FIGURE FOR PEN PLOTTER

      ELSEIF (IND.EQ.6) THEN
C  INITIALIZE FOR DRAWING NEXT PICTURE
         OPEN( UNIT=11, FILE=FILPLT, STATUS='NEW' )
         REWIND 11
         WRITE ( 11, '('' L0;'')' )

         PIXEL = 2000. * IPAPER / 100.
C?         WRITE (*,*) 'PIXEL=',PIXEL
         NCOLOR = 8

      ELSEIF (IND.EQ.8) THEN
C TEMPORARY RELEASE FROM GRPHICS  (USUALLY FOR TEXT)

      ELSEIF (IND.EQ.9) THEN
C RETURN TO GRAPHICS FROM TEMPORARY RELEASE

      ELSEIF (IND.EQ.10) THEN
C DONE DRAWING PICTURE
*  PUT PEN TO HOME
         WRITE ( 11, '('' H;;F0;'')')
         CLOSE(UNIT=11)

      ELSEIF ( IND.EQ.99) THEN
* SELECT NEW COLOR, THE VALUE IS IN X
         ICOLOR = INT( X )
         IF ( ICOLOR .GT. NCOLOR ) THEN
            ICOLOR = NCOLOR
         ELSEIF( ICOLOR .LT. 1 ) THEN
            ICOLOR = 1
         ENDIF
         WRITE ( 11, '('' H;F'',I1,'';'')' ) ICOLOR

      ELSE
C WE HAVE AN ERROR IN IND
         WRITE ( *, *) ' ERROR IN PLOT, IND=',IND

      ENDIF
      RETURN
      END
