FUNCTION rd_modb, mo_wkno, mo_label, all=all, $ uniq_sides=uniq_sides, label=label ; --------------------------------------------------------- ; --------------------------------------------------------- all=keyword_set(all) or 1-keyword_set(mo_wkno) ; USE MO Database with "mo_wkno" to determine the week ; and files to copy to the MO. infil = concat_dir('$DIR_GEN_MO', 'mdm') restgen, mdm, file=infil ;Get MO disk map n = n_elements(mdm) ; slf - 7-july generate label using array operations (eliminate for) mods =string(mdm.mo_disk,format='(i3.3)') sides=string(reform(mdm.st$side,1,n)) labs =string(reform(mdm.st$label,12,1,n)) weeks=string(reform(mdm.st$week,6,1,n)) ffid =string(reform(mdm.st$first_fid,11,1,n)) lfid =string(reform(mdm.st$last_fid,11,1,n)) nfid =string(mdm.nfid,format='(i5)') ; fmt = '(i3.3, a, 2x, a, 3x, a, 6x, a, 2x, a, i5)' ; orig format label= $ mods + sides + ' ' + labs + ' ' + weeks + ' ' + $ ffid + ' ' + lfid + nfid label_sides = strmid(label, 0, 18) ss = uniq(label_sides) usides = label_sides(ss) ;unique MO label sides umdm = mdm(ss) ;unique MO database ; Check if the user has pre-selected mo and wk IF Keyword_set(all) then begin mdm2do = mdm ;return all mo_label = label ;return all labels uniq_sides=strmid(mo_label(ss),0,4) uniq_sides=uniq_sides(sort(uniq_sides)) ENDIF ELSE BEGIN IF n_elements(mo_wkno) eq 0 THEN BEGIN iside = wmenu_sel(usides, /one) if (iside(0) eq -1) then stop ;aborted side2do = usides(iside) side2do = side2do(0) ;turn into scalar ss2 = where(label_sides eq side2do) if (n_elements(ss2) eq 1) then begin ;which week on that side? ipart = 0 end else begin ipart = wmenu_sel(label(ss2), /one) if (ipart(0) eq -1) then stop ;aborted endelse mdm2do = mdm(ss2(ipart)) ;the TODO mdm ENDIF ELSE BEGIN mdm2do = mdm(mo_wkno) ;use the passed value (scaler) iside = where( usides eq label_sides(mo_wkno) ) if iside(0) eq -1 then stop ;aborted iside = iside(0) ENDELSE tt = string(mdm2do.mo_disk, format='(i3.3)') ; slf - had to protect against subscript overflow ; (when making the 'last' mo in the data base, iside+1 overflows if (string(mdm2do.st$side) eq 'A') then begin tape_label = tt + ' ' + string(umdm(iside).st$label) if iside lt n_elements(umdm)-1 then $ tape_label=tape_label + $ ' / ' + string(umdm(iside+1).st$label) end else begin tape_label = tt + ' ' + string(umdm(iside-1).st$label) + $ ' / ' + string(umdm(iside).st$label) endelse mo_label = tape_label ENDELSE ;not all return, mdm2do END