    	SUBROUTINE LAYOUT_SET( TEXT )
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY,  JUN-1986
C
C	THIS ROUTINE SETS SOME LAYOUT ATTRIBUTES.
C
    	CHARACTER KEY*3, TEXT*(*)

    	NCH = IFMISC_NEXT( TEXT )
     	IF( NCH.EQ.0 ) THEN
     	    CALL LAYOUT_ERROR(3)
     	    RETURN
     	ENDIF
C
C  SET GIN PICK APERTURE...
C
    	KEY = TEXT(1:3)
     	IF( KEY .EQ. 'APE' ) THEN
     	    CALL LAYOUT_SET_PAP( TEXT )
    	    GOTO 999
     	ENDIF
C
C  SET BLINKING FEATURE...
C
     	IF( KEY .EQ. 'BLI' ) THEN
     	    CALL LAYOUT_SET_BLINK( 1 )
    	    GOTO 999
     	ENDIF
C
C  SET DIALOG AREA LINES...
C
     	IF( KEY .EQ. 'DAL' ) THEN
     	    CALL LAYOUT_SET_LINE( TEXT )
    	    GOTO 999
     	ENDIF
C
C  SET THE 8 FUNCTION KEYS...
C
     	IF( KEY .EQ. 'FKE' ) THEN
     	    CALL LAYOUT_SET_FKEYS
     	    GOTO 999
     	ENDIF
C
C  SET REFERENCE ORIGIN...
C
     	IF( KEY .EQ. 'ORI' ) THEN
     	    CALL LAYOUT_SET_ORIGIN( TEXT )
    	    GOTO 999
     	ENDIF
C
C  SET LAYOUT SCALE...
C
     	IF( KEY .EQ. 'SCA' ) THEN
     	    CALL LAYOUT_SET_SCALE( TEXT )
     	    GOTO 999
     	ENDIF
C
C  SET CHORD ANGLE...
C
     	IF( KEY .EQ. 'CHO' ) THEN
     	    CALL LAYOUT_SET_CHORD( TEXT )
     	    GOTO 999
     	ENDIF
C
C  SET PROGRAM FRAME ON/OFF...
C
     	IF( KEY .EQ. 'FRA' ) THEN
     	    CALL LAYOUT_SET_FRAME
     	    GOTO 999
     	ENDIF
C
C  SET PLOTTING STYLUS...
C
     	IF( KEY .EQ. 'LIN' ) THEN
     	    CALL LAYOUT_SET_STYLUS( TEXT )
     	    GOTO 999
     	ENDIF
C
C  SET DIFILE  OR HARDCOPY ON/OFF...
C
     	IF( KEY .EQ. 'HAR' ) THEN
     	    CALL LAYOUT_SET_HARDCOPY( TEXT )
     	    GOTO 999
     	ENDIF

999	RETURN
    	END

     	SUBROUTINE LAYOUT_SET_BLINK( ICODE )
C
C	THIS ROUTINE SETS ENTRY HIGHLIGHTING FOR LAYOUT.
C
C	ICODE = 0: RELEASE ALL PICKED ENTRIES WITH BLINK OFF.
C	ICODE = 1: FLIP-FLOP BLINKING OF PICKED ENTRIES.
C
     	INCLUDE 'LAYOUT.CBS'

    	IF( ICODE.NE.0 ) THEN
     	    BLINK = -BLINK
    	    DO I=1, NLG
     		CALL IFSEG_BLINK( BLINK*NLS(I) )
    	    ENDDO
    	ELSE
     	    IF( BLINK.GT.0 ) THEN
     		DO I=1, NLG
     		   CALL IFSEG_BLINK( -NLS(I) )
     		ENDDO
     	    ENDIF
    	    NLG = 0
    	ENDIF

     	CALL IFINIT_DUMP

999	RETURN
    	END

     	SUBROUTINE LAYOUT_SET_LINE( TEXT )
C
C  THIS ROUTINE SETS THE DIALOGUE AREA LINES
C
     	CHARACTER TEXT*(*)

     	NCH = IFMISC_NEXT( TEXT )
    	DLINE = 3.0
    	IF( NCH.GT.0 ) THEN
    	    NCH = IFMISC_DECODE( TEXT, 1, DLINE, IDUM )
    	    IF( NCH.EQ.0 ) THEN
     		CALL LAYOUT_ERROR(2)
     	    ELSE
    	        IF( DLINE.GT.30.0 ) DLINE = 30.0
     	    ENDIF
    	ENDIF
    	CALL IFINIT_LINE( -INT(DLINE) )

     	RETURN
     	END

     	SUBROUTINE LAYOUT_SET_FKEYS
C
C	THIS ROUTINE DEFINES/UNDEFINES F KEYS.
C
     	INCLUDE 'LAYOUT.CBS'

     	FKEYS = -FKEYS
     	IF( FKEYS.GT.0 ) CALL IFMAC_MACROS( 1 )
     	IF( FKEYS.LT.0 ) CALL IFMAC_MACROS( 0 )

     	RETURN
     	END

     	SUBROUTINE LAYOUT_SET_FRAME
C
C	THIS ROUTINE SETS THE VISIBILITY OF PROGRAM FRAME.
C
     	INCLUDE 'LAYOUT.CBS'

     	FRAME = -FRAME
     	CALL IFSEG_HIDE( 1*FRAME )	!FRAME
     	CALL IFSEG_HIDE( 2*FRAME )	!REFERENCE ORIGIN
     	CALL IFSEG_HIDE( 3*FRAME )	!WORKING ORIGIN
     	CALL IFSEG_HIDE( 4*FRAME )	!FKEY DEFINITIONS
     	IF( ISCP.NE.0 ) CALL IFSEG_HIDE( 5*FRAME )	!LAYOUT-SCALE
	CALL IFINIT_DUMP

     	RETURN
     	END

     	SUBROUTINE LAYOUT_SET_ORIGIN( TEXT )
C
C  THIS ROUTINE SETS THE REFERENCE ORIGIN FOR LAYOUT.
C
     	INCLUDE 'LAYOUT.CBS'
     	CHARACTER TEXT*(*)
     	DIMENSION RP(2), KP(2)

     	NCH = IFMISC_NEXT( TEXT )
     	IF( NCH.EQ.0 ) THEN
    	    XORS = 0.0
    	    YORS = 0.0
    	ELSE
    	    NCH = IFMISC_DECODE( TEXT, 2, RP, KP )
    	    IF( NCH.EQ.0 ) THEN
     		CALL LAYOUT_ERROR(2)
     	    ELSE
     		IF( KP(1).EQ.1 ) XORS = RP(1)
     		IF( KP(2).EQ.1 ) YORS = RP(2)
     	    ENDIF
    	ENDIF
    	CALL IFSEG_MOVE( 3, XORS, YORS )
     	IF( ISCP.GT.0 ) CALL LAYOUT_SET_RULER
    	CALL IFINIT_DUMP

     	RETURN
     	END

    	SUBROUTINE LAYOUT_SET_SCALE( TEXT )
C
C  PROGRAMMER: R.S. ZHOU		MARCH-1986
C
C	THIS ROUTINE PUTS ON THE BACKGROUND SCALE
C	WHICH HELPS CURSOR LOCATION FOR LAYOUT.
C
    	INCLUDE 'LAYOUT.CBS'
     	CHARACTER KEY*3, KWD(7)*3, TEXT*(*)
     	DIMENSION RP(5), KP(5)
     	DATA KWD/ 'WHI','RED','GRE','BLU','CYA','PUR','YEL' /

     	NCH = IFMISC_NEXT( TEXT )
     	IF( NCH.GT.0 ) THEN
     	    KEY = TEXT(1:3)
     	    DO IK=1, 7
     	       IF( KEY.EQ.KWD(IK) ) GOTO 100
     	    ENDDO
     	    IR = 1
     	    GOTO 200
100	    IR = 2
     	    ISCP = IK
     	    KP(1) = 0
     	    NCH = IFMISC_NEXT( TEXT )
     	    IF( NCH.EQ.0 ) GOTO 888
200	    NCH = IFMISC_DECODE( TEXT, 6-IR, RP(IR), KP(IR) )
    	    IF( NCH.EQ.0 ) GOTO 888
    	    IF(KP(1).EQ.1.AND.RP(1).GT.0..AND.RP(1).LT.8.00) ISCP= RP(1)
    	    IF(KP(2).EQ.1.AND.RP(2).GT.0..AND.RP(2).LT.100.) MAXS= RP(2)
    	    IF(KP(3).EQ.1.AND.RP(3).GT.0..AND.RP(3).LT.100.) MIXS= RP(3)
    	    IF(KP(4).EQ.1.AND.RP(4).GT.0..AND.RP(4).LT.100.) MAYS= RP(4)
    	    IF(KP(5).EQ.1.AND.RP(5).GT.0..AND.RP(5).LT.100.) MIYS= RP(5)
     	    CALL LAYOUT_SET_RULER
    	    CALL IFINIT_DUMP
     	ELSE IF( ISCP.EQ.0 ) THEN	!FLIP ON
    	    ISCP = 1
     	ELSE				!FLIP OFF
    	    ISCP = 0
    	ENDIF
     	CALL LAYOUT_SET_RULER
    	CALL IFINIT_DUMP
     	GOTO 999
888	CALL LAYOUT_ERROR(2)	!ERROR IN COMMAND PARAMETERS

999	RETURN
    	END

    	SUBROUTINE LAYOUT_SET_RULER
C
C  PROGRAMMER: R.S. ZHOU	MARCH-1986
C
C	THIS ROUTINE PUTS ON THE BACKGROUND SCALE
C	THROUGH THE CURRENT GRAPH ORIGIN FOR LAYOUT PLOTTING.
C
     	INCLUDE 'LAYOUT.CBS'

     	IF( ISCP.EQ.0 ) THEN
     	    CALL IFSEG_OPEN( -5 )
     	    RETURN
     	ENDIF
C
C  REORIGIN TO (XORS,YORS)...
C
     	CALL IFPLOT( XORS, YORS, -9 )
     	CALL IFSEG_OPEN(-5 )
     	CALL IFSEG_OPEN( 5 )
     	CALL IFSPEN( ISCP )
C
C  INITIALIZE...
C
     	MAX = IABS(MAXS)
     	MIX = IABS(MIXS)
     	MAY = IABS(MAYS)
     	MIY = IABS(MIYS)
     	XSP = 10.0/(MAX*MIX)
     	YSP = 10.0/(MAY*MIY)
     	IF( XSP.LT.0.01 ) XSP = 0.01
     	IF( YSP.LT.0.01 ) YSP = 0.01
        XPS1 = -XORG-XORS
    	XPS2 = 9.97-XORG-XORS
    	YPS1 = -YORG-YORS
    	YPS2 = 7.64-YORG-YORS
C
C  PUT A CROSS THROUGH THE ORIGIN...
C
     	CALL IFPLOT( XPS1, 0.0, 3 )
     	CALL IFPLOT( XPS2, 0.0, 2 )
     	CALL IFPLOT( 0.0, YPS1, 3 )
     	CALL IFPLOT( 0.0, YPS2, 2 )
C
C  DRAW THE SCALE...
C
    	XPS = 0.0
    	IMK = 0
1	XPS = XPS - XSP
    	IF( XPS.LT.XPS1 ) GOTO 2
    	ADD = 0.02
    	IMK = IMK + 1
    	IF( IMK.EQ.MIX ) THEN
    	    ADD = 0.06
    	    IMK = 0
    	ENDIF
     	CALL IFPLOT( XPS, -ADD, 3 )
     	CALL IFPLOT( XPS,  ADD, 2 )
    	GOTO 1

2	XPS = 0.0
    	IMK = 0
3	XPS = XPS + XSP
    	IF( XPS.GT.XPS2 ) GOTO 4
    	ADD = 0.02
    	IMK = IMK + 1
    	IF( IMK.EQ.MIX ) THEN
    	    ADD = 0.06
    	    IMK = 0
    	ENDIF
    	CALL IFPLOT( XPS, -ADD, 3 )
     	CALL IFPLOT( XPS,  ADD, 2 )
    	GOTO 3

4	YPS = 0.0
    	IMK = 0
5	YPS = YPS - YSP
    	IF( YPS.LT.YPS1 ) GOTO 6
    	ADD = 0.02
    	IMK = IMK + 1
    	IF( IMK.EQ.MIY ) THEN
    	    ADD = 0.06
    	    IMK = 0
    	ENDIF
     	CALL IFPLOT( -ADD, YPS, 3 )
     	CALL IFPLOT(  ADD, YPS, 2 )
    	GOTO 5

6	YPS = 0.0
    	IMK = 0
7	YPS = YPS + YSP
    	IF( YPS.GT.YPS2 ) GOTO 999
    	ADD = 0.02
    	IMK = IMK + 1
    	IF( IMK.EQ.MIY ) THEN
    	    ADD = 0.06
    	    IMK = 0
    	ENDIF
     	CALL IFPLOT( -ADD, YPS, 3 )
     	CALL IFPLOT(  ADD, YPS, 2 )
    	GOTO 7

999	CALL IFSEG_OPEN( 0 )
     	CALL IFPLOT( -XORS, -YORS, -9 )

     	RETURN
    	END

    	SUBROUTINE LAYOUT_SET_CHORD( TEXT )
C
C  PROGRAMMER: R.S. ZHOU		MARCH-1986
C
C	THIS ROUTINE SETS THE CHORD ANGLE IN DEGREES
C	FOR DRAWING ARCS.
C
     	INCLUDE 'LAYOUT.CBS'
     	CHARACTER TEXT*(*)

     	NCH = IFMISC_NEXT( TEXT )
    	IF( NCH.GT.0 ) THEN
    	    NCH = IFMISC_DECODE( TEXT, 1, DUMY, IDUM )
    	    IF( NCH.EQ.0 ) THEN
     		CALL LAYOUT_ERROR( 2 )
     	    ELSE IF( DUMY.GE.0.5 .AND. DUMY.LE.15.0 ) THEN
     		CHORD = DUMY
    	    ENDIF
     	ENDIF

     	RETURN
     	END

     	SUBROUTINE LAYOUT_SET_PAP( TEXT )
C
C  THIS ROUTINE SETS THE GIN PICK APERTURE.
C
     	INCLUDE 'LAYOUT.CBS'
     	CHARACTER TEXT*(*)

     	NCH = IFMISC_NEXT( TEXT )
     	APER = 0.1
    	IF( NCH.GT.0 ) THEN
    	    NCH = IFMISC_DECODE( TEXT, 1, APER, IDUM )
    	    IF( NCH.EQ.0 ) THEN
     		CALL LAYOUT_ERROR(2)
     	    ELSE
     		IF( APER.LT.0.01 ) APER = 0.01
     		IF( APER.GT.1.00 ) APER = 1.00
     	    ENDIF
    	ENDIF
    	CALL IFGIN_PAP( APER )
    	CALL IFINIT_DUMP

     	RETURN
     	END

     	SUBROUTINE LAYOUT_SET_STYLUS( TEXT )
C
C	THIS ROUTINE SETS PLOTTING STYLUS --- LINETYPE AND LINEWIDTH.
C
     	INCLUDE 'LAYOUT.CBS'
     	CHARACTER TEXT*(*)
     	DIMENSION RP(2), KP(2)

     	NCH = IFMISC_NEXT( TEXT )
     	IF( NCH.GT.0 ) THEN
    	    NCH = IFMISC_DECODE( TEXT, 2, RP, KP )
    	    IF( NCH.EQ.0 ) THEN
     		CALL LAYOUT_ERROR(2)
     	    ELSE
     		IF( KP(1).EQ.1 ) THEN
     		    IF( RP(1).GT.0.0.AND.RP(1).LT.11.0 ) LTYP=RP(1)
     		ENDIF
     		IF( KP(2).EQ.1 ) THEN
     		    IF( RP(2).GT.0.0.AND.RP(2).LT.11.0 ) LWID=RP(2)
     		ENDIF
     	    ENDIF
    	ENDIF

     	RETURN
     	END

    	SUBROUTINE LAYOUT_SET_VISS
C
C  PROGRAMMER: R.S. ZHOU		JUNE-1986
C
C	THIS ROUTINE SETS PICKED LAYOUT SEGMENT VISIBILITY.
C
    	INCLUDE 'LAYOUT.CBS'

     	LVISS = -LVISS
    	DO I=1, NLG
     	    CALL IFSEG_HIDE( LVISS*NLS(I) )
    	ENDDO
     	CALL IFINIT_DUMP

    	RETURN
    	END

     	SUBROUTINE LAYOUT_SET_HARDCOPY( TEXT )
C
C	THIS ROUTINE SETS FLAG FOR PREPARATION OF HARDCOPY DIFILE.
C
     	CHARACTER TEXT*(*)

     	NCH = IFMISC_NEXT( TEXT )
     	IF( NCH.GT.0 ) THEN
     	    IF( TEXT(1:2).EQ.'ON' ) THEN
     		CALL IFINIT_DIF(1)
     	    ELSE IF( TEXT(1:3).EQ.'OFF' ) THEN
     		CALL IFINIT_DIF(0)
     	    ELSE
     		CALL LAYOUT_ERROR(2)
     	    ENDIF
     	ELSE
     		CALL LAYOUT_ERROR(3)
     	ENDIF
     	RETURN
     	END

