     	SUBROUTINE IFQAST_CTRLY
C
C  PROGRAMMER:  R.S. ZHOU
C		BOSTON COLLEGE, 1/89
C
C	THIS ROUTINE QUEUES AN ASYNCHRONOUS SYSTEM TRAP (AST)
C	FOR "CTRL_Y" INTERRUPT.
C
     	INCLUDE  'TEKLIB.CBS'
     	INCLUDE  '($IODEF)'
     	INTEGER   CODE
     	EXTERNAL  IFQAST_DCTRLY
C
C  DISABLE DCL DETECTION OF CTRL_Y ...
C
     	MASK = 2**25
     	CALL LIB$DISABLE_CTRL( %REF(MASK) )
C
C  OPEN INPUT CHANNEL FOR TERMINAL...
C
     	CALL SYS$ASSIGN( 'SYS$INPUT:', %REF(MASK), , )
C
C  QUEUE THE AST...
C
     	CODE = IO$_SETMODE .OR. IO$M_CTRLYAST
     	CALL SYS$QIOW( , %VAL(MASK), %VAL(CODE),
     +  , , , IFQAST_DCTRLY, , , , , )

     	RETURN
     	END

     	SUBROUTINE IFQAST_DCTRLY
C
C	THIS ROUTINE DELIVERS AN AST FOR "CTRL_Y" INTERRUPT
C	TO CLEAN UP GRAPHICS TERMINAL AND THEN EXIT.
C
C	NEW OUTPUT CHANNEL IS NEEDED TO AVOID RECURSIVE I/O.
C
     	INCLUDE 'TEKLIB.CBS'
     	LUN = 51
    	OPEN( UNIT=LUN, FILE='SYS$OUTPUT:', STATUS='NEW',
     +        FORM='FORMATTED', CARRIAGECONTROL='NONE' )
     	CALL IFINIT_EXIT
     	CALL EXIT
     	END

     	SUBROUTINE IFQAST_CTRLC
C
C	THIS ROUTINE QUEUES AN ASYNCHRONOUS SYSTEM TRAP (AST)
C	FOR "CTRL_C" INTERRUPT.
C
     	INCLUDE  'TEKLIB.CBS'
     	INCLUDE  '($IODEF)'
     	INTEGER   CODE
     	EXTERNAL  IFQAST_DCTRLC
C
C  OPEN INPUT CHANNEL FOR TERMINAL...
C
     	CALL SYS$ASSIGN( 'SYS$INPUT:', %REF(NCC), , )
C
C  QUEUE THE AST...
C
     	CODE = IO$_SETMODE .OR. IO$M_CTRLCAST
     	CALL SYS$QIOW( , %VAL(NCC), %VAL(CODE),
     +  , , , IFQAST_DCTRLC, , , , , )
C
C  CLEAR THE FLAG...
C
     	CTRL_C = .FALSE.

     	RETURN
     	END

     	SUBROUTINE IFQAST_DCTRLC
C
C	THIS ROUTINE DELIVERS AN AST FOR "CTRL_C" INTERRUPT.
C	"CTRL_C" FLAG IS MONITORED IN FOLLOWING SUBROUTINES
C	IN TEKLIB:
C
C	IFINIT_PLOT_END --- PLOT SESSION TERMINATION.
C	IFINIT_DUMP ------- GRAPHICS BUFFER DUMP.
C	IFPLOT ------------ VECTOR DRAWING.
C	IFPLOT ------------ VECTOR DRAWING.
C	IFLINE ------------ POLYLINE DRAWING.
C	IFAXIS ------------ AXIS DRAWING.
C	IFFILL ------------ AREA FILLING.
C
C	SO THAT A USER CAN ABORT A PLOT AND STILL GET BACK
C	TO THE DIALOGUE MENU.
C
     	INCLUDE 'TEKLIB.CBS'

     	CTRL_C = .TRUE.
     	RETURN
     	END

     	LOGICAL FUNCTION IFCTRL_C()
C
C	THIS ROUTINE REPORTS THE "CTRL_C" FLAG.
C
     	INCLUDE 'TEKLIB.CBS'
     	IFCTRL_C = CTRL_C
     	RETURN
     	END

     	SUBROUTINE IFQAST_CLEAR
C
C	THIS ROUTINE CLEARS THE "CTRL_C" FLAG.
C
     	INCLUDE 'TEKLIB.CBS'

     	IF( .NOT.CTRL_C ) THEN
     	    CALL SYS$DASSGN( %VAL(NCC) )
     	ELSE
     	    CTRL_C = .FALSE.
     	ENDIF

     	RETURN
     	END

