pro rd_hxa, infil, data
;
;+
;NAME:
;	RD_HXA
;PURPOSE:
;	Read and extract the HXA scan portion of the ADA file.
;CALLING SEQUENCE:
;	Rd_HXA, infil, data
;INPUT:
;	infil   : input file specification
;OUTPUT:
;	data	: structure with HXA scan data in it
;HISTORY:
;	Written 6-Mar-92 by Mons Morrison
;	14-May-92 (MDM) - zero out data variable before reading - free up memory
;	22-Sep-93 (MDM) - Moved close command to the proper level
;-
;
;
att_struct
att_old_struct
;
get_lun, lun
hxa_scan_head = {hxa_scan_head_rec}
qfirst = 1
data = 0	;free up memory
;
nfiles = n_elements(infil)
for ifil=0,nfiles-1 do begin
    openr, lun, infil(ifil), /block
    ;
    rd_pointer, lun, pointer
    ibyt = pointer.opt_section
    if (ibyt ne -1) then begin
	rdwrt, 'R', lun, ibyt, 0, hxa_scan_head, 1
	if (hxa_scan_head.nEntries ne 0) then begin
	    hxa_scan = replicate({hxa_scan_rec}, hxa_scan_head.nEntries)
	    rdwrt, 'R', lun, ibyt, 0, hxa_scan, 1
	    if (qfirst) then begin
		data = hxa_scan
		qfirst = 0
	    end else begin
		data = [data, hxa_scan]
	    end
	end
    end
    close, lun		;moved 22-Sep-93
end
;
free_lun, lun
end
