function hvalue,file,keyword,EXTEN=exten ;NAME:hvalue ; ;PURPOSE:look through the header of file to find the keyword specified and get ;that value ; ;CALLING SEQUENCE:hvalue('file','keyword',EXTEN=exten) ; ;INPUTS: file: the fits file with a header ; keyword: the header keyword that you want the value of ; ;OPTIONAL KEYWORD:EXTEN : extention number of the header you want to read ; if not supplied, it will be set to 0 ; ;OUTPUTS:value of the keyword - will always be a string ; ;SIDE EFFECTS:? ; ;RESTRICTIONS: you must convert any numerical values after this is called ; ;EXAMPLES: print, hvalue('sedIOC_1.fits', 'SM_POS ',EXTEN=3) ; ;MODIFICATION HISTORY:Started on 1/9/03 by Myra Blaylock ; ;------------------------------------ if N_params() LT 2 then begin print,'Syntax - keyword_value= hvalue( filename,keyword,[ EXTEN= #])' return, -1 endif if not keyword_set(exten) then exten = 0 header='' header=HEADFITS(file,EXTEN=exten) line='' hh = strtrim(header,2) if size(keyword,/tname) NE 'STRING' then keyword = strtrim(keyword,2) flag = strpos(hh,keyword) g = where(flag NE -1, Ng) if Ng NE 1 then begin Print,'Either no such keyword or more than one.' value=-999 endif else begin line=hh(g) value=strtrim(strmid(line,10 ,20),2) endelse return,value end