;+
; Project     : SOHO - CDS     
;                   
; Name        : WMAX()
;               
; Purpose     : Return the max value of the data in a Spectral Window.
;               
; Explanation : Straightforward.
;               
; Use         : MAX_COUNT = WMAX(QLDS,WINDOW)
;    
; Inputs      : QLDS:	A "CDS QL data structure"
;               
;		WINDOW:	String or number specifying a spectral window 
;		in the QLDS
;			
; Opt. Inputs : None.
;               
; Outputs     : Return value.
;               
; Opt. Outputs: None.
;               
; Keywords    : NOCHECK:Set to skip call to QLMGR
;
; Calls       : QLMGR, WINDOWNO()
;
; Common      : None.
;               
; Restrictions: None.
;               
; Side effects: None.
;               
; Category    : CDS, QuickLook
;               
; Prev. Hist. : None.
;
; Written     : Stein Vidar Hagfors Haugan, October 1993
;               
; Modified    : SVHH, 20 November 1993 - Documentation added.
;
; Version     : 1.0
;-            

FUNCTION Wmax,QLDS,wnd,NOCHECK=NOCHECK
  
  IF NOT Keyword_SET(NOCHECK) THEN BEGIN
      QLMGR,QLDS,valid
      On_Error,2
      IF NOT valid THEN	message,'Argument not a valid QL Data structure'
  EndIF
  
  wnd_no = windowno(QLDS,wnd,/NOCHECK)
  
  IF wnd_no eq 0 THEN BEGIN
      message,"Couldn't find window: "+trim(wnd),/continue
      message,'Window ID must be <1,..,'$
	      +trim(N_elements(QLDS.DetDesc))+'>',/continue
      message,'or a window name'
  END
  
;
; Shorthand
;
  
  return,QLDS.DetDesc(wnd_no-1).max
  
END
