      SUBROUTINE PLCTRL (XXX, YYY, M, N, IZ)
      IMPLICIT NONE
C
C ***      PLOT BUFFER CONTROL
C
      INTEGER M, N
      REAL XXX(M,N), YYY(M,N)
C
      INCLUDE MATLAB$KOM:SIZEPARMS.INC
C
      CHARACTER*1 IZ(VARSIZE)
C
      INCLUDE MATLAB$KOM:IOP.KOM
      INCLUDE MATLAB$KOM:MATPLT.KOM
      INCLUDE MATLAB$KOM:SAV.KOM
C
      INTEGER DSPLY, I, IANS, IERR
      CHARACTER*8 ICURS
C
      DATA ICURS / 'CNTROL>>' /
C
C
5     CONTINUE
      DSPLY = 0
      CALL CHKEND
      CALL DSSTRN (' PLEASE CHOOSE A PLOT BUFFER CONTROL OPTION:', 1)
      CALL DSSTRN (' [1] CLEAR THE BUFFER', 1)
      CALL DSSTRN (' [2] DELETE A PLOT', 1)
      CALL DSSTRN (' [3] SHOW THE PLOT BUFFER', 1)
      CALL DSSTRN (' [4] DISPLAY ONE OF THE SAVED PLOTS', 1)
      CALL DSSTRN (' [5] DISPLAY ALL SAVED PLOTS', 1)
      CALL DSSTRN (' [6] SAVE THE PLOT BUFFER', 1)
      CALL DSSTRN (' [7] RETURN TO THE MAIN MENU', 1)
      CALL DSCURS (ICURS)
      CALL VALGET (0, IANS, 'I')
      GO TO (100, 200, 200, 600, 300, 400, 500) IANS
      CALL MENUER (5)
C
100   CONTINUE
      PLTMAX = 0
      PLTCNT = 0
      DO 120 I = 1, 10
        IPLTYP(I) = 0
120   CONTINUE
      GO TO 500
C
200   CONTINUE
      CALL DSSTRN (' THE FOLLOWING PLOTS ARE STORED IN THE BUFFER:', 2)
      CALL DSSTRN (' BUFFER LOCATION   PLOT TYPE', 2)
      DO 290 I = 1, 10
        CALL DSSTRN ('          ', 0)
        CALL DSWDI (I, 0)
        CALL DSSTRN ('       ', 0)
        GO TO (220, 230, 240, 250, 260) IPLTYP(I)
        GO TO 290
C
220     CONTINUE
        CALL DSSTRN ('3-D PLOT', 1)
        GO TO 290
C
230     CONTINUE
        CALL DSSTRN ('X-Y PLOT', 1)
        GO TO 290
C
240     CONTINUE
        CALL DSSTRN ('HISTOGRAM', 1)
        GO TO 290
C
250     CONTINUE
        CALL DSSTRN ('CONTOUR PLOT', 1)
        GO TO 290
C
260     CONTINUE
        CALL DSSTRN ('POLAR PLOT', 1)
290   CONTINUE
C
      IF (IANS.EQ.2) THEN
        CALL DSSTRN (
     .      ' DELETE WHICH GRAPH?  ENTER THE BUFFER LOCATION.', 1)
        CALL DSCURS (ICURS)
        CALL VALGET (0, IANS, 'I')
        IF (IANS.GE.1 .AND. IANS.LE.10) THEN
          IPLTYP(IANS) = 0
        ENDIF
      ELSE
        CALL DSBLLN (2)
      ENDIF
      GO TO 5
C
300   CONTINUE
      CALL PLREST (XXX, YYY, M, N, DSPLY, IERR, IZ)
      GO TO 500
C
400   CONTINUE
      CALL SAVFIL
      GO TO 500
C
600   CONTINUE
      CALL DSSTRN (
     .    ' PLEASE ENTER THE PLOT BUFFER NUMBER TO BE DISPLAYED', 1)
      CALL DSCURS (ICURS)
      CALL VALGET (0, DSPLY, 'I')
      CALL PLREST (XXX, YYY, M, N, DSPLY, IERR, IZ)
      GO TO 5
C
500   CONTINUE
      RETURN
      END
