	function fh_r_key,header,key, error=error, character=character

;+
;	Function FH_R_KEY searches for a given keyword KEY in the specified
;	FITS header and returns value in the found line converted into
;	a floating-point, double precision variable if this line does not contain
;	apostrophe. Otherwise, string type variable is returned.
;		The keyword parameter ERROR returns 0 if search was successful, and 1
;	if the specified keyword was not found.
;		The case of the KEY value is not significant.
;		The keyword parameter has no effect and left for compatibility
;	with the previous version.
;
;	EXAMPLE:
;
;	VALUE=FH_R_KEY(header, 'NAXIS', error=error)
;	HELP, VALUE
;
;	WRITTEN by V.Grechnev, ISTP, May 1996
;-


N=n_elements(header)

error=1
Result=''
i=-1

Up_key=strupcase(key)

repeat i=i+1 until strcompress(strmid(header(i),0,8),/rem) eq Up_key or i eq N-1
Length=strlen(key)

	if i lt N-1 then begin
;if strpos(header(i),"'") ge 0 then $
;		Result=(strsplit(header(i), delim="'"))(1) else $
;		Result=double((strsplit(header(i)))(1+(Length lt 8)))

Left=strpos(header(i),"'")

	if Left ge 0 then begin
Next=Left
		repeat begin
Next=strpos(header(i),"'",Next+1)
if next ge 0 then Right=Next
		endrep until next lt 0
Result=strmid(Header(i), Left+1, Right-Left-1)
	endif else Result=double((strsplit(header(i)))(1+(Length lt 8)))

error=0
	endif

	return, Result

	end