     	SUBROUTINE IFCOPY( ARRAY, PLOTID )
C
C  PROGRAMMER:  RONG-SHENG ZHOU
C		BOSTON COLLEGE, 8/1988
C
C	THIS ROUTINE SETS UP HARDCOPY PLOT PAGES.
C
C	"ARRAY" SHOULD BE DIMENSIONED TO 20:
C
C	ARRAY(1): HARDCOPY DEVICE NUMBER.
C
C		1 => HP7550 PEN PLOTTER
C		2 => HP7221 PEN PLOTTER
C		3 => IMAGE/SLIDE  MAKER
C		4 => POSTSCRIPT PRINTER
C
C	ARRAY(2): NUMBER OF HARDCOPIES.
C	ARRAY(3): PLOT ID FLAG.
C	ARRAY(4): PAGE FEED FLAG.
C	ARRAY(5): HARDCOPY SETUP PARAMETER 1 (OFFSET X).
C	ARRAY(6): HARDCOPY SETUP PARAMETER 2 (OFFSET Y).
C	ARRAY(7): HARDCOPY SETUP PARAMETER 3 (SCALE  X).
C	ARRAY(8): HARDCOPY SETUP PARAMETER 4 (SCALE  Y).
C	........  ........
C	ARRAY(20): HARDCOPY SETUP PARAMETER 20.
C
C	PLOTID: PLOT ID LABEL
C
     	INCLUDE     'TEKLIB.CBS'
     	CHARACTER    TEXT*64, KEY*2, OUTPUT*32, IDPLOT*32, PLOTID*(*)
    	DIMENSION    RP(2), KP(2), ARRAY(1)
     	COMMON/IFCOPY/ SETUP(20), OUTPUT, IDPLOT
     	EQUIVALENCE (KEY,TEXT(1:2))
     	DATA SETUP/ 1.,1.,1.,1.,0,0,1.,1.,1.,0,5.,1.,1.,0,0,0,0,0,0,0 /

     	IDPLOT = PLOTID
     	IF( IDPLOT.EQ.' ' ) THEN
     	    IDPLOT = DTNAME
     	    NCHS = INDEX( IDPLOT, ']' )
     	    IF( NCHS.GT.0 ) IDPLOT = IDPLOT(NCHS+1:)
     	ENDIF
     	IF( IF_DCL_HARDCOPY() ) THEN
     	    CALL IFFEED( ARRAY(1), IDPLOT, OUTPUT )
     	    RETURN
     	ENDIF
     	IF( IDF.EQ.0 ) THEN
     	    CALL IFANSI_VIDEO(70)
     	    WRITE(6,1234)
1234	    FORMAT('_oops: Missing hardcopy meta-file.')
     	    RETURN
     	ENDIF
     	IF( ARRAY(1).NE.0.0 ) THEN
     	    DO  I=1, 20
     		SETUP(I) = ARRAY(I)
     	    ENDDO
     	ENDIF
     	CALL IFMISC_STRIP(OUTPUT)
     	CALL IFMISC_UPPER(OUTPUT)
C
C  LAYOUT DIALOGUE MENU...
C
     	CALL IFMAC_KEYEXP(0)
     	CALL IFCOPY_MENU
     	CALL IFCOPY_DATA(0)
C
C  START THE DIALOGUE LOOP...
C
111	CALL IFANSI_VIDEO(47)
     	CALL IFANSI_TEXT('HARDCOPY> ',10,21,1)
    	CALL IFANSI_CLEAR(4)
     	I = IFQIOW( NCHS, TEXT )
     	IF( I.EQ.0 ) GOTO 777
     	IF( I.EQ.26) GOTO 888
     	IF( NCHS.EQ.0 ) GOTO 999
     	NCHS = IFMISC_STRIP( TEXT )
     	CALL IFMISC_UPPER( TEXT )
     	IF( KEY.EQ.'QU' ) GOTO 888
     	IF( KEY.EQ.'EX' ) GOTO 999
C
C  REFRESH THE DIALOGUE MENU...
C
     	IF( I.EQ.27 ) THEN
     	    IF( KEY.EQ.'OP' ) THEN
     		CALL IFCOPY_MENU
     		CALL IFCOPY_DATA(0)
     	    ELSE
     		CALL IFANSI_VIDEO(70)
     		CALL IFANSI_TEXT(' Undefined function key.',24,20,6)
     	    ENDIF
     	    GOTO 111
     	ENDIF
C
C  CLEAR THE "OOPS" LINE...
C
     	CALL IFANSI_CURSOR(20,6)
    	CALL IFANSI_CLEAR(4)
C
C  DISPLAY THE ON-LINE HELP...
C
     	IF( TEXT(1:4).EQ.'HELP' ) THEN
     	    IF( NCHS.LT.6 ) THEN
     		CALL IFANSI_VIDEO(70)
     		CALL IFANSI_TEXT(' Missing HELP keyword.',22,20,6)
     	    ELSE
     	NCHS=IFMISC_HELP('GRAFIT$HLP:HARDCOPY.HLP',TEXT(6:NCHS),20,6)
     	    ENDIF
     	    GOTO 111
	ENDIF
C
C  DECODE THE NEW PARAMETERS...
C
     	IF( NCHS.LT.3 .OR. TEXT(3:3).NE.'=' ) GOTO 777
     	IF( KEY.EQ.'ID' ) THEN
     	    IDPLOT = TEXT(4:)
     	    NCHS = 12
     	    GOTO 555
     	ENDIF
     	IF( KEY.EQ.'OD' ) THEN
     	    OUTPUT = TEXT(4:)
     	    NCHS = 13
     	    GOTO 555
     	ENDIF
     	NCHS = NCHS-3
     	IF( NCHS.GT.0 ) NCHS=IFMISC_DECODE(TEXT(4:),2,RP,KP)
     	IF( NCHS.EQ.0 ) GOTO 777
C
C  STORE THE NEW PARAMETERS...
C
     	IF( KEY.EQ.'DV' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.1 .OR. NCHS.GT.4 ) GOTO 666
     	    SETUP(1) = NCHS
     	    NCHS = 1
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'NC' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.1 .OR. NCHS.GT.99 ) GOTO 666
     	    SETUP(2) = NCHS
     	    NCHS = 2
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'LB' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.0 .OR. NCHS.GT.1 ) GOTO 666
    	    SETUP(3) = NCHS
     	    NCHS = 3
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'PF' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.0 .OR. NCHS.GT.1 ) GOTO 666
    	    SETUP(4) = NCHS
     	    NCHS = 4
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'PO' ) THEN
     	    IF( KP(1).EQ.1 ) THEN
     		IF( ABS(RP(1)).GT.99.0 ) GOTO 666
     		SETUP(5) = RP(1)
     	    ENDIF
     	    IF( KP(2).EQ.1 ) THEN
     		IF( ABS(RP(2)).GT.99.0 ) GOTO 666
     		SETUP(6) = RP(2)
     	    ENDIF
     	    NCHS = 5
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'SF' ) THEN
     	    IF( KP(1).EQ.1 ) THEN
     		IF( RP(1).EQ.0.0 .OR. ABS(RP(1)).GT.9.0 ) GOTO 666
     		SETUP(7) = RP(1)
     	    ENDIF
     	    IF( KP(2).EQ.1 ) THEN
     		IF( RP(2).EQ.0.0 .OR. ABS(RP(2)).GT.9.0 ) GOTO 666
     		SETUP(8) = RP(2)
     	    ENDIF
     	    NCHS = 6
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'LW' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.1 .OR. NCHS.GT.9 ) GOTO 666
    	    SETUP(9) = NCHS
     	    NCHS = 7
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'VP' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.0 .OR. NCHS.GT.1 ) GOTO 666
    	    SETUP(10) = NCHS
     	    NCHS = 8
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'PS' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.1 .OR. NCHS.GT.9 ) GOTO 666
    	    SETUP(11) = NCHS
     	    NCHS = 9
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'FT' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.1 .OR. NCHS.GT.9 ) GOTO 666
    	    SETUP(12) = NCHS
     	    NCHS = 10
     	    GOTO 555
     	ENDIF

     	IF( KEY.EQ.'BC' ) THEN
     	    NCHS = RP(1)
     	    IF( NCHS.LT.1 .OR. NCHS.GT.9 ) GOTO 666
    	    SETUP(13) = NCHS
     	    NCHS = 11
     	    GOTO 555
     	ENDIF
     	GOTO 666

555	CALL IFCOPY_DATA(NCHS)
     	GOTO 111
666	CALL IFANSI_VIDEO(70)
     	CALL IFANSI_TEXT(' Parameter out of range.', 24,20,6)
    	GOTO 111
777	CALL IFANSI_VIDEO(70)
     	CALL IFANSI_TEXT(' Invalid input.', 15,20,6)
    	GOTO 111
888	NCHS = -1
C
C  DUMP THE HARDCOPY...
C
999	CALL IFANSI_CURSOR(16,1)
     	CALL IFANSI_CLEAR(2)
     	IF( NCHS.GE.0 ) CALL IFFEED(SETUP(1),IDPLOT,OUTPUT)
     	CALL IFMAC_KEYEXP(1)
     	DO I=1, 20
     	   ARRAY(I) = SETUP(I)
     	ENDDO
     	PLOTID = IDPLOT
     	RETURN
    	END

     	SUBROUTINE IFCOPY_MENU
C
C	THIS ROUTINE LAYOUTS DIALOGUE MENU FOR HARDCOPY PAGE SETUP.
C
     	CALL IFINIT_LINE(24)
    	CALL IFANSI_VIDEO(80)
    	CALL IFANSI_VIDEO(90)
     	CALL IFANSI_TEXT('              M E N U   O F   H A R D
     + C O P Y   P A G E   S E T U P              ', 80, 1, 1 )
    	CALL IFANSI_VIDEO(47)
	WRITE(6,1000)
1000	FORMAT(
     + 5x'NC= 0 .............'
     +,' Number of hardcopies to make ...... Maximum 99.'/
     +,5x'LB= 0 .............'
     +,' Plot ID labeling .................. 0=Off, 1=On.'/
     +,5x'PF= 0 .............'
     +,' Plot page feed upon finish ........ 0=Off, 1=On.'/
     +,5x'LW= 0 .............'
     +,' Plotting stylus/linewidth ......... Bold lines.'/
     +,5x'VP= 0 .............'
     +,' Vertical page alignment ........... 0=Off, 1=On.'/
     +,5x'PS= 0 .............'
     +,' Pen speed for a pen plotter ....... 1 to 9.'/
     +,5x'FT= 0 .............'
     +,' Film type for SlideMaker ..........'/
     +,5x'BC= 0 .............'
     +,' Background color for SlideMaker ...'/
     +,5x'DV= 0 .............'
     +,' Hardcopy device intended ...'/
     +,5x'PO=             ...'
     +,' Plot offsets (x,y) ................ In inches.'/
     +,5x'SF=             ...'
     +,' Overall scale factors (x,y) ....... Enlarge/Shrink.'/
     +,5x'ID=',30X,' ... Plot ID label.'/
     +,5x'OD=',30X,' ... Optional destination for hardcopy.')
     	CALL IFANSI_VIDEO(90)
     	WRITE(6,1001)
1001	FORMAT(X,80(' '))
     	CALL IFANSI_VIDEO(47)
     	WRITE(6,1002)
1002	FORMAT(' To change the setup, enter AC=parameters where AC',
     +' is the 2 letter Access-Code'/' for the setup parameter.   ',
     +' Enter HELP AC to get more information on setup AC.'/
     +' Press RETURN to send hardcopy, CTRL/Z to quit, PF1 to',
     +' refresh the screen.')
     	CALL IFANSI_VIDEO(90)
     	WRITE(6,1003)
1003	FORMAT(X,80(' '))
     	CALL IFANSI_VIDEO(47)
     	WRITE(6,1005)
1005	FORMAT(' oops:')
     	RETURN
     	END

     	SUBROUTINE IFCOPY_DATA(ICODE)
C
C	THIS ROUTINE INSERTS HARDCOPY PAGE-SETUP PARAMETERS.
C
     	CHARACTER OUTPUT*32, IDPLOT*32
     	COMMON/IFCOPY/ SETUP(20), OUTPUT, IDPLOT
     	CHARACTER DEVICE(4)*25, TEXT*16
     	DATA DEVICE(1) / ' HP7550-HPGL pen plotter ' /
     	DATA DEVICE(2) / 'HP7221-serial pen plotter' /
     	DATA DEVICE(3) / 'PT-HPGL Image/Slide-Maker' /
     	DATA DEVICE(4) / 'PostScript laser printer ' /

     	I = ICODE
     	CALL IFANSI_VIDEO(30)
    	IF(I.EQ.0.OR.I.EQ.2) CALL IFANSI_IFL(INT(SETUP(2)),1,2,2,8)
    	IF(I.EQ.0.OR.I.EQ.3) CALL IFANSI_IFL(INT(SETUP(3)),1,2,3,8)
    	IF(I.EQ.0.OR.I.EQ.4) CALL IFANSI_IFL(INT(SETUP(4)),1,2,4,8)
     	IF(I.EQ.0.OR.I.EQ.7) CALL IFANSI_IFL(INT(SETUP(9)),1,2,5,8)
     	IF(I.EQ.0.OR.I.EQ.8) CALL IFANSI_IFL(INT(SETUP(10)),1,2,6,8)
     	IF(I.EQ.0.OR.I.EQ.9) CALL IFANSI_IFL(INT(SETUP(11)),1,2,7,8)
     	IF(I.EQ.0.OR.I.EQ.10) THEN
     	   ID = SETUP(12)+0.1
     	   CALL IFANSI_IFL(ID,1,2,8,8)
     	   TEXT = ' '
     	   IF( ID.EQ.1 ) TEXT = 'Ektachrome-100'
     	   IF( ID.EQ.2 ) TEXT = 'Polaroid polac'
     	   CALL IFANSI_TEXT( TEXT, 16, 8, 61 )
     	ENDIF
     	IF(I.EQ.0.OR.I.EQ.11) THEN
     	   ID = SETUP(13)+0.1
     	   CALL IFANSI_IFL(ID,1,2,9,8)
     	   TEXT = ' '
     	   IF( ID.EQ.1 ) TEXT = 'Black'
     	   IF( ID.EQ.2 ) TEXT = 'Medium-gray'
     	   IF( ID.EQ.3 ) TEXT = 'Dark-blue'
     	   IF( ID.EQ.4 ) TEXT = 'Medium-blue'
     	   IF( ID.EQ.5 ) TEXT = 'Light-gray'
     	   IF( ID.EQ.6 ) TEXT = 'Red'
     	   CALL IFANSI_TEXT( TEXT, 16, 9, 61 )
     	ENDIF
     	IF(I.EQ.0.OR.I.EQ.1) THEN
     	   ID = SETUP(1)+0.1
     	   IF( ID.LT.1 ) ID = 1
     	   IF( ID.GT.4 ) ID = 4
     	   CALL IFANSI_IFL(ID,1,2,10,8)
     	   CALL IFANSI_TEXT(DEVICE(ID),25,10,52)
     	ENDIF
    	IF(I.EQ.0.OR.I.EQ.5) CALL IFANSI_FFL(SETUP(5),2,6.2,11,8)
    	IF(I.EQ.0.OR.I.EQ.6) CALL IFANSI_FFL(SETUP(7),2,6.3,12,8)
     	IF(I.EQ.0.OR.I.EQ.12) CALL IFANSI_TEXT(IDPLOT,30,13,8)
     	IF(I.EQ.0.OR.I.EQ.13) CALL IFANSI_TEXT(OUTPUT,30,14,8)

     	RETURN
     	END

