pro mk_mo_list, list, outfil=outfil, mdm=mdm, labels=labels
;
;+
;NAME:
;	mk_mo_list
;PURPOSE:
;	This is a program to write a list of the files that go on the MO disk
;	archive.
;SAMPLE CALLING SEQUENCE:
;	mk_mo_list
;	mk_mo_list, outfil='mk_mo_list.txt'
;HISTORY:
;	Written 20-May-93 by M.Morrison 
;	26-May-93 (MDM) - Corrected where it printed the label in the list
;			  when there were three weeks on a MO side
;-
;
infil = concat_dir('$DIR_GEN_MO', 'mdm')
if (n_elements(mdm) eq 0) then restgen, mdm, file=infil			;MO Disk Map
;
n = n_elements(mdm)
list = strarr(n)
labels = strarr(n)
fmt1 = '(i3.3, a1, 2x, a12)'
fmt2 = '(3x, a, 6x, a, 2x, a, i5)'
last_label = 'xx'
for i=0,n-1 do begin
    mdm0 = mdm(i)
    label0 = string(mdm0.mo_disk, string(mdm0.st$side), string(mdm0.st$label), format=fmt1)
    if (label0 eq last_label) then label = string(replicate(32b, strlen(label))) else label = label0
    str = string(string(mdm0.st$week), string(mdm0.st$first_fid), string(mdm0.st$last_fid), mdm0.nfid, format=fmt2)
    labels(i) = label0
    list(i) = label + str
    last_label = label0
end
;
header = ['MK_MO_LIST.PRO  Ver 1.1   ', 'Program Run: '+!stime, ' ']
if (keyword_set(outfil)) then prstr, [header, list], file=outfil
;
end
