	SUBROUTINE GETPLQUAL(clip,QF,DF,SQRTF,LINF,LOGF,
	1	sizef,TITLEF,FILELBL,GRIDF,STKF,STKSET,
	2	FIRSTF,INDIVF,HARDF,XLIMLO,XLIMHI,YLIMLO,YLIMHI,ixstack,
	3	iystack,XLOW,XHIGH,YLOW,YHIGH,XLEN,YLEN,XMAR,YMAR,wavel)

	LOGICAL clip,QF,DF,SQRTF,LINF,sizef,TITLEF,FILELBL,GRIDF
	LOGICAL STKF,STKSET,FIRSTF,INDIVF,HARDF
	LOGICAL XLIMLO,XLIMHI,YLIMLO,YLIMHI
	INTEGER ixstack, iystack
	REAL XLOW,XHIGH,YLOW,YHIGH
	REAL XLEN,YLEN,XMAR,YMAR,wavel

	include 'cmpr.common'

	INTEGER STATUS,CLI$GET_VALUE,CLI$PRESENT,lib$spawn
	EXTERNAL CLI$_PRESENT,CLI$_DEFAULTED,CLI$_ABSENT,CLI$_NEGATED
	LOGICAL FLAG,GET_NUMBER,GET_LOGICAL,GET_FNUMBER
	
C Set default for x-axis units
	QF = .false.		! true = plot in Q
	DF = .false.		! true = plot d-spaces
	WAVEL = 0.0		! set non-zero to convert files to a wavelength
C				  before plotting
	IF (XUNITDF .eq. 1) then
	  DF = .true.		! true = plot d-spaces
	ELSEIF (XUNITDF .eq. 2) then
	  IF (WAVE0 .le. 0) THEN
	    WRITE(LO,'(A)') ' Unable to plot in fixed wavelength'//
	1	' no default wavelength has been set',
	2	' Will plot in default units.'
	  ELSE
	    WAVEL = wave0
	  ENDIF
	ELSEIF (XUNITDF .eq. 3) then
	  QF = .true.		! true = plot in Q
	ENDIF

C Set default for y-axis units
	SQRTF = .false.		! true = plot as SQRT(intensity)
	LOGF = .false.		! true -- plot LOG(intensity)
	LINF = .true.		! true -- plot linear (default)
!	IF (YUNITDF .eq. 0) then
!	  LINF = .true.		! true -- plot linear
!	ELSEIF (YUNITDF .eq. 1) then
	IF (YUNITDF .eq. 1) then
	  SQRTF = .true.		! true = plot as SQRT(intensity)
	ELSEIF (YUNITDF .eq. 2) then
	  LOGF = .true.		! true = plot as LOG(intensity)
	ENDIF

C Set default for y axis scaling
	FIRSTF = .false.	! true -- scale to FIRST file
	INDIVF = .false.	! true -- scale each plot RELATIVE to maximum
	IF (YSCLDF .eq. 1) then
	  FIRSTF = .true.
	ELSEIF (YSCLDF .eq. 2) then
	  INDIVF = .true.
	ENDIF

C Set default for number of boxes
	STKF = .false.		! true if /STACK, false if /NOSTACK
	STKSET = .false.	! true if /STACK or /NOSTACK specified
	IXSTACK = XSTAKDF
	IYSTACK = YSTAKDF
	IF (BOXDF .eq. 1) then
	  STKSET = .true.	! true if /STACK or /NOSTACK specified
	ELSEIF (BOXDF .eq. 2) then
	  STKSET = .true.	! true if /STACK or /NOSTACK specified
	  STKF = .true.		! all files in separate boxes
	ENDIF
C Set default for misc options
	clip = .false.
C clip	= .true.  -- offscale lines are "squared off" (like a recorder)
C	= .false. -- offscale lines not plotted (invisible) 
	sizef = .false.		! true if /SIZE specified
	GRIDF = .FALSE.		! true if /GRID, false if /NOGRID
	TITLEF = .false.	! true if /TITLE specified
	FILELBL = .false.	! true if /FILE specified, false for /NOFILE
	IF (MOD(MISCDF,2) .eq. 1) then
	  clip = .true.
	ENDIF
	IF (MOD(MISCDF/2,2) .eq. 1) then
	  GRIDF = .TRUE.		! true if /GRID, false if /NOGRID
	ENDIF
	IF (MOD(MISCDF/4,2) .eq. 1) then
	  FILELBL = .true.	! true if /FILE specified, false for /NOFILE
	ENDIF
	IF (MOD(MISCDF/8,2) .eq. 1) then
	  TITLEF = .true.	! true if /TITLE specified
	ENDIF
	IF (MOD(MISCDF/16,2) .eq. 1) then
	  SIZEF = .true.	! true if /SIZE specified
	ENDIF


	XLIMLO = .false.	! true if /XLOW specified
	XLIMHI = .false.	! true if /XHIGH specified
	YLIMLO = .false.	! true if /YLOW specified
	YLIMHI = .false.	! true if /YHIGH specified
	hardf = .false.		! true -- plot on screen
C......................................................................
C............. Parse the qualifiers from the command string............

C Q qualifier
	IF (CLI$PRESENT('Q')) THEN
	  QF = .true. 
	  DF = .false.
	ENDIF
C Dspace  qualifier
	IF (CLI$PRESENT('DSPACE')) THEN
	  DF = .true. 
	  QF = .false.
	ENDIF
C WAVELENGTH qualifier
	IF (CLI$PRESENT('WAVELENGTH')) THEN
	  QF = .false.
	  DF = .false.
	  FLAG = GET_FNUMBER('WAVELENGTH',wavel)
	ENDIF

C STACK qualifiers
	IF (CLI$PRESENT('STACK') .eq. %LOC(CLI$_NEGATED)) THEN
	  STKSET = .true.
	  STKF = .true.
	ELSEIF (CLI$PRESENT('XSTACK') .or. CLI$PRESENT('YSTACK') .or. 
	1	CLI$PRESENT('STACK')) then
	  STKSET = .true.
	  STKF = .false.
	  FLAG = GET_NUMBER('XSTACK',IXSTACK)
	  FLAG = GET_NUMBER('YSTACK',IYSTACK)
	ENDIF

C Y axis Scaling qualifiers
	IF (CLI$PRESENT('FIRST')) THEN
	  FIRSTF = .true.
	  INDIVF = .false.
	ELSEIF (CLI$PRESENT('RELATIVE')) THEN
	  INDIVF = .true.
	  FIRSTF = .false.
	ELSEIF (CLI$PRESENT('EXTREME')) THEN
	  INDIVF = .false.
	  FIRSTF = .false.
	ENDIF

C SQRT qualifier
	IF (CLI$PRESENT('SQRT')) THEN
	  SQRTF = .true.
	  LOGF = .false.
	  LINF = .false.
	ENDIF
C LINEAR qualifier

	IF (CLI$PRESENT('LINEAR')) THEN
	  LINF = .true.
	  LOGF = .false.
	  SQRTF = .false.
	ENDIF
C LOG qualifier
	IF (CLI$PRESENT('LOG')) THEN
	  LOGF = .true.
	  SQRTF = .false.
	  LINF = .false.
	ENDIF

C GRID qualifier
	IF (CLI$PRESENT('GRID') .eq. %LOC(CLI$_PRESENT)) GRIDF = .true.
C NOGRID qualifier
	IF (CLI$PRESENT('GRID') .eq. %LOC(CLI$_NEGATED)) GRIDF = .false.

C TITLE qualifier
	IF (CLI$PRESENT('TITLE').eq.%LOC(CLI$_PRESENT)) TITLEF = .true.
C NOTITLE qualifier
	IF (CLI$PRESENT('TITLE').eq.%LOC(CLI$_NEGATED)) TITLEF = .false.

C CLIP qualifier
	IF (CLI$PRESENT('CLIP') .eq. %LOC(CLI$_PRESENT)) clip = .true.
C NOCLIP qualifier
	IF (CLI$PRESENT('CLIP') .eq. %LOC(CLI$_NEGATED)) clip = .false.

C FILE qualifier
	IF (CLI$PRESENT('FILE').eq.%LOC(CLI$_PRESENT)) FILELBL = .true.
C NOFILE qualifier
	IF (CLI$PRESENT('FILE').eq.%LOC(CLI$_NEGATED)) FILELBL = .false.

C HARD qualifier
	IF (CLI$PRESENT('HARD')) HARDF = .true.

C XLOW and XHIGH qualifier
	IF (CLI$PRESENT('XLOW')) THEN
	  FLAG = GET_FNUMBER('XLOW',XLOW)
	  IF (.not. FLAG) XLIMLO = .true.
	ENDIF
	IF (CLI$PRESENT('XHIGH')) THEN
	  FLAG = GET_FNUMBER('XHIGH',XHIGH)
	  IF (.not. FLAG) XLIMHI = .true.
	ENDIF

C YLOW and YHIGH qualifier
	IF (CLI$PRESENT('YLOW')) THEN
	  FLAG = GET_FNUMBER('YLOW',YLOW)
	  IF (.not. FLAG) YLIMLO = .true.
	ENDIF
	IF (CLI$PRESENT('YHIGH')) THEN
	  FLAG = GET_FNUMBER('YHIGH',YHIGH)
	  IF (.not. FLAG) THEN
	    YLIMHI = .true.
	    FIRSTF = .true.
	  ENDIF
	ENDIF

	IF (CLI$PRESENT('SIZE')) THEN
	  sizef = .true.
	  XLEN = 0.
	  YLEN = 0.
	  XMAR = 1.
	  YMAR = 1.
	  FLAG = GET_FNUMBER('SIZE',xlen)
	  FLAG = GET_FNUMBER('SIZE',Ylen)
	  FLAG = GET_FNUMBER('SIZE',xmar)
	  FLAG = GET_FNUMBER('SIZE',ymar)
	ENDIF
	RETURN
	END
