     	SUBROUTINE IFSPEN( IPEN )
C
C  PROGRAMMER: R.S. ZHOU	SEP-1986
C
C  	THIS ROUTINE SETS ACTIVE COLOR TEXT-INDEX AND LINE-INDEX.
C
	INCLUDE 'TEKLIB.CBS'

     	IPN = IABS(IPEN)
     	IF( IPN.LT.1 .OR. IPN.GT.7 ) IPN = 1
     	IF( IPN.EQ.ILP ) RETURN

     	IF( ITM.EQ.1 ) GOTO 888
C
C  SET THE WRITING COLOR...
C
     	IF( ITM.EQ.2 ) THEN		!TEK-4100 GRAPHICS
     	    IF( IPL.GT.NBS-IPK-8 ) CALL IFINIT_DUMP
    	    IPB(IPL+1) = 27		!<ESC>ML index: LINE INDEX
    	    IPB(IPL+2) = 77
    	    IPB(IPL+3) = 76
    	    IPB(IPL+4) = 48 + IPN
    	    IPL = IPL + 4
    	    IPB(IPL+1) = 27		!<ESC>MT index: TEXT INDEX
    	    IPB(IPL+2) = 77
    	    IPB(IPL+3) = 84
    	    IPB(IPL+4) = 48 + IPN
    	    IPL = IPL + 4
    	ENDIF

    	IF( ITM.EQ.3 ) THEN		!REGIS GRAPHICS
     	    IF( IPL.GT.NBS-IPK-5 ) CALL IFINIT_DUMP
    	    IPB(IPL+1) = 'W'
    	    IPB(IPL+2) = '('
    	    IPB(IPL+3) = 'I'
    	    IF( IPN.EQ.1 ) IPB(IPL+4) = 55
    	    IF( IPN.GT.1 ) IPB(IPL+4) = 47 + IPN
    	    IPB(IPL+5) = ')'
    	    IPL = IPL + 5
    	ENDIF

888	IF( IDW.NE.0 ) THEN
     	    IF( NPPS.GT.0 ) CALL IFPLOT_DUMP
     	    WRITE(IDF,1000) IPN
     	ENDIF
1000	FORMAT('SPEN:',I3)
     	ILP = IPN			!SAVE THE CURRENT PEN

999	RETURN
    	END

     	SUBROUTINE IFSPEN_NOW( IPEN )
C
C	THIS ROUTINE REPORTS THE CURRENT PEN NUMBER IN "IPEN".
C
     	INCLUDE 'TEKLIB.CBS'

     	IPEN = ILP

999	RETURN
     	END

