function HEADPDS, filename,remain,SILENT=silent ;+ ; NAME: ; HEADPDS ; PURPOSE: ; Read a PDS label into an array variable. ; ; CALLING SEQUENCE: ; Result=HEADPDS (filename [,remain,/SILENT]) ; ; INPUTS: ; FILENAME = Scalar string containing the name of the PDS file ; to be read. ; ; OUTPUTS: ; Result = PDS label array constructed from designated record. ; ; ; OPTIONAL INPUT KEYWORDS: ; ; SILENT - Normally, HEADPDS will give a message if the keyword, ; 'OBJECT' is not found in the PDS label. The SILENT keyword will ; suppress this ; ; REMAIN - returns any extra text after the label, if any exists ; ; EXAMPLE: ; Read a PDS file TEST.PDS into a PDS header array, lbl. ; IDL> lbl = HEADPDS( 'TEST.PDS') ; ; PROCEDURES USED: ; Functions: PDSPAR ; ; MODIFICATION HISTORY: ; Adapted by John D Koch,from READFITS by Wayne Landsman,August,1994 ; ;---------------------------------------------------------------------------- On_error,2 ;Return to user ; Check for filename input params = N_params() if params(0) LT 1 then begin print,'Syntax - result = HEADPDS( filename [,remain,/SILENT] )' return, -1 endif ; Open file openr, unit, filename, ERROR = err, /GET_LUN, /BLOCK if err LT 0 then begin if !VERSION.OS EQ 'vms' then filename = strupcase(filename) message,'Error opening file ' + ' ' + filename free_lun,unit endif status = fstat(unit) pointlun = 0 nbytes = status.size ; Read PDS label information a = assoc(unit,bytarr(nbytes)) lbl = string(a(0)) + ' ' +string(10b) jump = 2 lf = where(byte(lbl) EQ 13b,lines) if lines LE 0 then begin lf = where(byte(lbl) EQ 10b,lines) jump = 1 endif label = strarr(lines) k = 0 label(k) = strmid(lbl,0,lf(k))+string(10b) k=1 r = k while k LT lines do begin label(k)= strmid(lbl,lf(k-1)+jump,lf(k)-lf(k-1)-jump)+string(10b) eol = strpos(label(k),10b) if strtrim(strmid(label(k),0,eol),2) EQ 'END' then k = lines k = k+1 r = r+1 endwhile ; Read object to determine type of data in file if not keyword_set(SILENT) then begin object = pdspar(label,'OBJECT') if !ERR EQ -1 then message, $ 'WARNING -'+filename+' missing OBJECT keyword',/CONTINUE endif ; Read any text following the label, if asked for if params(0) GT 1 then begin rlines = lines-r-1 remain = strarr(rlines) i = 0 while r LT lines-1 do begin remain(i) = strmid(lbl,lf(r-1)+jump,lf(r)-lf(r-1)-jump)+string(10b) r = r+1 i = i+1 endwhile endif ; Return the label and release the file unit return, label free_lun,unit end