pro rd_sld, sttim, entim, index, data, infil=infil, old=old ; ; qdebug = 1 ; if (not keyword_set(infil)) then begin weeks = week_loop(sttim, entim) ; qinfil = 0 end else begin weeks = -1 qinfil = 1 end ; sxt_struct, sxt_leak=data_ref ; exten = 'a.01' ; qfirst_time = 1 for iweek=0,n_elements(weeks)-1 do begin if (not qinfil) then begin filnam = string(weeks(iweek).year, weeks(iweek).week, exten, format="('sld', i2.2, '_', i2.2, a)") infil = concat_dir('$DIR_SXT_SLD', filnam) end if (qdebug) then print, infil ; if (not file_exist(infil)) then goto, skip ;sorry - afterthought ; openr, lun, infil, /get_lun, /block rd_fheader, infil, fhead rd_pointer, infil, pointer ; ibyt = pointer.data_section ndatasets = fhead.ndatasets ; rd_index, infil, ibyt, index_ref index0 = replicate(index_ref, ndatasets) data0 = replicate(data_ref, ndatasets) ; for i=0,ndatasets-1 do begin rdwrt, 'R', lun, ibyt, 0, index_ref, 1 rdwrt, 'R', lun, ibyt, 0, data_ref, 1 index0(i) = index_ref data0(i) = data_ref end ; if (qfirst_time) then begin data = data0 index = index0 qfirst_time = 0 index_version = get_index_ver(index0(0)) end else begin data = [data, data0] chk_index_version = get_index_ver(index0(0)) if (total(chk_index_version-index_version) gt 0) then begin ;only change the output structure type if the change ;was from a old to a new. New to old does not ;require a new output index structure type index_tmp = replicate(index0(0), n_elements(index)) ;make output structure the data type of the latest structure for i=0,n_elements(index_tmp)-1 do index_tmp(i) = str_copy_tags(index0(0), index(i)) ;copy old structure into new index = index_tmp index_version = get_index_ver(index0) end if (total(chk_index_version-index_version) lt 0) then begin ;reading old data after new data - output array is new data index_tmp = replicate(index(0), n_elements(index0)) ;make output structure the data type of the output structure for i=0,n_elements(index_tmp)-1 do index_tmp(i) = str_copy_tags(index(0), index0(i)) ;copy old structure into new index0 = index_tmp ;now the IDL append will work end index = [index, index0] end ; free_lun, lun skip: end ; end