pro rd_ada_data, lun, ibyt, idset, nout, index, data, roadmap, sel_dsets, pointer
;+
;NAME:
;	RD_ADA_DATA
;PURPOSE:
;	Perform the actual data read for ADA files (called from RD_XDA)
;INPUT:
;	lun	- the logical unit number where the file is open
;	ibyt	- the starting byte value to read from
;	idset	- the dataset number for the output matrix
;	nout	- the total number of datasets to be extracted
;	index	- the index structure for all output datasets
;	roadmap	- the roadmap
;	sel_dsets- the indicies of the datasets selected for extraction
;	pointer	- pointer structure used to determine the data 
;		  structure version
;INPUT/OUTPUT:
;	data	- the data
;HISTORY:
;	written 21-Mar-92 by Mons Morrison
;-
;
common rd_ada_data_blk, data0, data_version
;
att_struct
att_old_struct
;
if (idset eq 0) then begin
    data0 = get_data_rec('ada', pointer(0))
    data  = replicate(data0, nout)
    data_version = pointer(0).data_version
end
if (index(idset).gen.ndatabyte eq 0) then return

if (pointer.data_version gt data_version) then begin
    data0 = get_data_rec('ada', pointer(0))
    data_tmp  = replicate(data0, nout)             ;make output structure the data type of the latest structure
    for i=0,idset-1 do data_tmp(i) = str_copy(data0, data(i))    ;copy old structure into new
    data = data_tmp
    data_version = pointer(0).data_version
end

rdwrt, 'R', lun, ibyt, 0, data0, 1
data(idset) = data0
;
end
