function read_ecs_hdr,fname 
; 
;   reads the ECS telemetry file header in PVL format 
;   and creates a structure entry: 
; 
;              filename    = file name 
;              date_cre    = creation date  
;              date_st     = start date  
;              date_end    = ending date 
;              npack       = number of packets 
; 
; @(#)read_ecs_hdr.pro	1.1 01/23/98 :LASCO IDL LIBRARY
;
openr,lu,fname,/get_lun 
s = '' 
b={ecs_tm,filename:'',apid:'',date_cre:'',date_st:'',date_end:'',npack:0L} 
repeat begin 
   readf,lu,s 
   s = strtrim(s,2) 
   neq = strpos(s,'=')
   if (neq lt 0) then begin
      key=s
   endif else begin
      key = strupcase(strmid(s,0,neq))  
      val = strtrim(strmid(s,neq+1,strlen(s)),2) 
   endelse
   case key of 
   'FILENAME':  b.filename=val 
   'APID':      b.apid=val 
   'DATE_CRE':  b.date_cre=val 
   'STARTIME':  b.date_st=val 
   'ENDTIME':   b.date_end=val 
   'NUM_PACK':  b.npack=long(val) 
   else: 
   endcase 
endrep until (key eq 'END') 
close,lu 
free_lun,lu 
return,b 
end 

