C---------------------------------------------------------------------------
      SUBROUTINE SETATTR(ISP, JFIL, IVAL, FVAL, SETDEF, ASKFL, IGNFIX)
C---------------------------------------------------------------------------
	INTEGER ISP,JFIL(*)

	LOGICAL SETDEF, ASKFL, IGNFIX
C if SETDEF is true, all values will first be set to defaults 
C if ASKFL is true, the subroutine will request values where values have 
C		not been specified
C if IGNFIX is true, the IVAL variables will be ignored
	INTEGER IVAL(*)
C To specify default values for an attribute, set the attribute
C To specify fixed values for an attribute, code IVAL(1), with that value
C   or use -1 which causes the value to be ignored.
C  IVAL(1)  contains the value for color attributes
C  IVAL(2)  contains the value for line width attributes
C  IVAL(3)  contains the value for line type attributes
C  IVAL(4)  contains the value for peak type attributes
C  IVAL(5)  contains -1 if FVAL(1) should be ignored (plot offset)
C  IVAL(6)  contains -1 if FVAL(2) should be ignored (plot magnification)
	REAL    FVAL(*)
C  FVAL(1)  contains the value for the offset to be added to the plot
C  FVAL(2)  contains the value for the magnification factor
C---------------------------------------------------------------------------

	include 'cmpr.common'
	LOGICAL ANYPEAKS

	IF (IGNFIX) THEN
	  IVAL(1) = -1
	  IVAL(2) = -1
	  IVAL(3) = -1
	  IVAL(4) = -1
	  IVAL(5) = -1
	  IVAL(6) = -1
	ENDIF

C if SETDEF is true -- set all attributes to their default values
C     also, set IFILE to the first specified file and
C	    set ANYPEAKS if any of the file(s) have peaks

	ANYPEAKS = .false.
	DO I=ISP,1
	  IFILE = JFIL(I)  
	  IF (npks(ifile) .gt. 0)  ANYPEAKS = .true.
	  IF (ifile .GT. 0 .and. ifile .le. m$FIL .and. SETDEF) THEN
	    PCOLOR(ifile) = ifile
	    PWIDTH(ifile) = 1
	    PLTYP(ifile) = 1
	    IF (npoint(ifile) .le. 0 .and. npks(ifile) .gt. 0) THEN
	      PPEAKS(ifile) = 1
	    ELSE
	      PPEAKS(ifile) = 0
	    ENDIF
	    PLOFF(ifile) = 0.0
	    PLMAG(ifile) = 1.0
	  ENDIF
	ENDDO

1	FORMAT('$Enter the ',a,' (? for help) [default=',i2,']: ')

C now ask for values
	IF (ASKFL .and. IVAL(1) .lt.0) THEN
10	  WRITE(LO,1) 'COLOR index',PCOLOR(ifile)
	  READ (LI,fmt='(Q,I)',end=999,iostat=j) I,IVAL(1)
	  IF (j .ne. 0) THEN
	    call HELP1('ATTRIBUTES /COLOR','cmpr_hlp',prompt)
	    goto 10
	  ENDIF
	  IF (I .eq. 0) IVAL(1) = -1
	ENDIF

	IF (ASKFL .and. IVAL(2) .lt.0) THEN
20	  WRITE(LO,1) 'WIDTH index',PWIDTH(ifile) 
	  READ (LI,fmt='(Q,I)',end=999,iostat=j) I,IVAL(2)
	  IF (j .ne. 0) THEN
	    call HELP1('ATTRIBUTES /WIDTH','cmpr_hlp',prompt)
	    goto 20
	  ENDIF
	  IF (I .eq. 0) IVAL(2) = -1
	ENDIF

	IF (ASKFL .and. IVAL(3) .lt.0) THEN
30	  WRITE(LO,1) 'LINE type', PLTYP(ifile)
	  READ (LI,fmt='(Q,I)',end=999,iostat=j) I,IVAL(3)
	  IF (j .ne. 0) THEN
	    call HELP1('ATTRIBUTES /LINE','cmpr_hlp',prompt)
	    goto 30
	  ENDIF
	  IF (I .eq. 0) IVAL(3) = -1
	ENDIF

 	IF (ASKFL .and. ANYPEAKS .and. IVAL(4) .lt.0) THEN
40	  WRITE(LO,1) 'linetype for PEAK plotting', Ppeaks(ifile) 
	  READ (LI,fmt='(Q,I)',end=999,iostat=j) I,IVAL(4)
	  IF (j .ne. 0) THEN
	    call HELP1('ATTRIBUTES /PEAK','cmpr_hlp',prompt)
	    goto 40
	  ENDIF
	  IF (I .eq. 0) IVAL(4) = -1
	ENDIF

2	FORMAT('$Enter the ',a,' (? for help) [default=',G10.3,']: ')
 	IF (ASKFL .and. IVAL(5) .lt. 0) THEN
50	  WRITE(LO,2) 'plot offset (added to data)', PLOFF(ifile)
	  READ (LI,fmt='(Q,f10.0)',end=999,iostat=j) I,FVAL(1)
	  IF (j .ne. 0) THEN
	    call HELP1('ATTRIBUTES /OFFSET','cmpr_hlp',prompt)
	    goto 50
	  ENDIF
	  IVAL(5) = 0
	  IF (I .eq. 0) IVAL(5) = -1
	ENDIF

 	IF (ASKFL .and. IVAL(6) .lt. 0) THEN
60	  WRITE(LO,2) 'plot magnification factor', PLMAG(ifile)
	  READ (LI,fmt='(Q,f10.0)',end=999,iostat=j) I,FVAL(2)
	  IF (j .ne. 0) THEN
	    call HELP1('ATTRIBUTES /OFFSET','cmpr_hlp',prompt)
	    goto 60
	  ENDIF
	  IVAL(6) = 0
	  IF (I .eq. 0) IVAL(6) = -1
	ENDIF

C now set the attributes
999	DO I=ISP,1
	  IFILE = JFIL(I)  
	  IF (npks(ifile) .gt. 0)  ANYPEAKS = .true.
	  IF (ifile .GT. 0 .and. ifile .le. m$FIL) THEN
	    IF (IVAL(1) .ge. 0) PCOLOR(ifile) = IVAL(1)
	    IF (IVAL(2) .ge. 0) PWIDTH(ifile) = IVAL(2)
	    IF (IVAL(3) .ge. 0) PLTYP(ifile) = IVAL(3)
	    IF (IVAL(4) .ge. 0) Ppeaks(ifile) = IVAL(4)
	    IF (IVAL(5) .ge. 0) PLOFF(ifile) = FVAL(1)
	    IF (IVAL(6) .ge. 0) PLMAG(ifile) = FVAL(2)
	    IF (Npks(ifile) .le. 0) PPEAKS(ifile) = 0
	  ENDIF
	ENDDO
	RETURN
	END
C---------------------------------------------------------------------------
      SUBROUTINE CLRATTR(IVAL, FVAL)
C---------------------------------------------------------------------------
	INTEGER IVAL(*)
C To specify default values for an attribute, set the attribute
C To specify fixed values for an attribute, code IVAL(1), with that value
C   or use -1 which causes the value to be ignored.
C  IVAL(1)  contains the value for color attributes
C  IVAL(2)  contains the value for line width attributes
C  IVAL(3)  contains the value for line type attributes
C  IVAL(4)  contains the value for peak type attributes
C  IVAL(5)  contains -1 if FVAL(1) should be ignored (plot offset)
C  IVAL(6)  contains -1 if FVAL(2) should be ignored (plot magnification)
	REAL    FVAL(*)
C  FVAL(1)  contains the value for the offset to be added to the plot
C  FVAL(2)  contains the value for the magnification factor
C---------------------------------------------------------------------------
	IVAL(1) = -1
	IVAL(2) = -1
	IVAL(3) = -1
	IVAL(4) = -1
	IVAL(5) = -1
	IVAL(6) = -1
	FVAL(1) = 0.
	FVAL(2) = 1.
	RETURN
	END
