	FUNCTION mo2wks, mo_side, molabel=molabel, tape=tape, fid=fid, $
			debug=debug
;	--------------------------------------------------------------
;+							18-May-93
;	NAME: mo2wks
;
;	PURPOSE: Get a list of archive tapes contain on a MO side.
;
;	CALLING SEQUENCE:
;
;		tape_weeks = mo2wks( mo_side, [/molabel, /tape, /fid] )
;
;	INPUT:
;		mo_side	  requested mo side ex. '014B' or '018a'
;		
;	OPTIONAL INPUT:
;		molabel	  if set will print MO label
;		tape	  if set will print MT dev # and archive tape
;		fid	  if set will print first and last fids for 
;				each tape archive week section.	
;				
;	OUTPUT:	
;		tape_weeks 	list of weeks for that mo side
;
;	HISTORY:
;		10-Apr-93, written by gal
;		16-Apr-93, added fid switch for to print 1st and last
;			file ID on each week.
;		18-May-93, added label switch
;
;-
;	--------------------------------------------------------------

        infil = concat_dir('$DIR_GEN_MO', 'mdm')
        restgen, mdm, file=infil                        ;MO Disk Map

        n = n_elements(mdm)
        label = strarr(n)
        fmt = '(i3.3, a, 2x, a, 3x, a, 6x, a, 2x, a, i5)'
        for i=0,n-1 do begin
          mdm0 = mdm(i)
          label(i) = string(mdm0.mo_disk, string(mdm0.st$side), string(mdm0.st$label), string(mdm0.st$week), $
           string(mdm0.st$first_fid), string(mdm0.st$last_fid),mdm0.nfid, format=fmt)
        end

	label_sides = strmid(label, 0, 18)

        ss = uniq(label_sides)
        usides = label_sides(ss)
        umdm = mdm(ss)

          
        IF n_elements(mo_side) ne 0 THEN BEGIN	;MO side(s) defined
            mo_side = strupcase(mo_side)
            mo_sides = strmid(label,0,4)        ;pick-off sides names
            ss2 = where(mo_sides eq mo_side, ntapes)
            If (ntapes lt 1) THEN BEGIN         ;error in pick
              Print, 'Error: invalid choice of MO SIDE'
              return,''
            ENDIF
        ENDIF ELSE BEGIN
            iside = wmenu_sel(usides, /one)     ;PICK MO SIDE
            if (iside(0) eq -1) then stop           ;aborted
            side2do = usides(iside)
            side2do = side2do(0)            ;turn into scalar

            ss2 = where(label_sides eq side2do)         ;selected MOside
        ENDELSE
        wks = string(mdm(ss2).st$week)                ;selected weeks

	IF keyword_set(molabel) THEN BEGIN
	  mdm2do = mdm(ss2(0))		;use the 1st of the set
	  iside = where( usides eq label_sides(ss2(0)) )
	  if iside(0) eq -1 then stop	;error
	  iside = iside(0)		;scaler
	  tt = string(mdm2do.mo_disk, format='(i3.3)')
          if (string(mdm2do.st$side) eq 'A') then begin
            tape_label = tt + '   ' + string(umdm(iside).st$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
          print, 'MO label: ', mo_label
	ENDIF

	IF keyword_set(tape) THEN BEGIN
	  ii = 0	;tape dev #
	  Print, '  '
	  Print, 'Place the following archive tapes into the'+ $
		' corresponding 8mm Tape drives:'
	  Print, '  '
	  Print, 'Tape drive #     Tape Archive Week Number
	  Print, '-----------------------------------------
	  For i = 0, n_elements(wks)-1 DO BEGIN
 	    Print, strtrim(Def_tapd(ii),2),'          ',strmid(wks(i),0,5)
	    ii = ii + 1			;increment for next tape
	    If ii eq 2 then ii = 0	;reset cause only two tape drives
	  ENDFOR
	  Print, '  '
	ENDIF
	IF keyword_set(fid) THEN BEGIN
	  Print, ' '
	  Print, ' MO     MO Label    Tape-Week    First FID    Last FID   # of FIDs
	  FOR i=0, n_elements(ss2)-1 DO BEGIN
	    print, label(ss2(i))
	  ENDFOR
	ENDIF

	If keyword_set(debug) THEN BEGIN
	  stop, 'Debug: stop in mo2wks'
	ENDIF

	RETURN, wks
	END
