pro rd_bsc_data, lun, ibyt, idset, nout, index, data, roadmap, sel_dsets
;+
;NAME:
;	RD_BSC_DATA
;PURPOSE:
;	Perform the actual data read for BSC 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
;INPUT/OUTPUT:
;	data	- the data
;HISTORY:
;	written 13-Nov-92 by Mons Morrison
;-
;
common rd_wda_data_blk, data0, nx, str_out, str_last
;
if (idset eq 0) then begin
    data0 = mk_bsc_str(roadmap=roadmap(sel_dsets), str=str)	;all selected datasets
    data  = replicate(data0,  nout)
    str_out = str
    str_last = str
end
if (index(idset).gen.ndatabyte eq 0) then return

data0 = mk_bsc_str(roadmap=roadmap(sel_dsets(idset)), str=str)	;dataset to read
;;if (str ne str_last) then data0 = make_str(str)

rdwrt, 'R', lun, ibyt, 0, data0, 1
;
if (str eq str_out) then begin
    data(idset) = data0
end else begin
    print, 'TODO - grab only the relevant tags and trim the length if necessary
    stop
end
;
str_last = str
end
