;+
;NAME:
;	go_tr_summary_head
;PURPOSE:
;	Simple front end for making per-image listing summaries
;HISTORY:
;	Written 29-Aug-97 by M.Morrison
;	11-Sep-97 (MDM) - Added some details for SEQ_VAL listings
;-
;
print, 'Do something like
print, "	IDL> sttim = '27-Aug-97'
print, 'to select the starting time to list'
print, ' '
;
ff0 = file_list('/tsw/dbase/cal/info', 'mhead_tab*')
ii = xmenu_sel(ff0, /one)
if (ii(0) eq -1) then stop
lstfil = ff0(ii)
qseq_val = 0
if (lstfil eq '/tsw/dbase/cal/info/mhead_tab_seq_val.lst') then begin
    yesnox, 'Is this for the official SEQ VAL RUNS database?', qseq_val, 'Y'
end
;
if (n_elements(sttim) eq 0) then sttim = '1-Jan-97'
if (n_elements(entim) eq 0) then entim = '1-Jan-99'

dirs = get_i0_dirs(sttim, entim)

ff = file_list(dirs, '*_001.fits', file=file)
ff = reverse(ff)
file = reverse(file)
;
ii = xmenu_sel(file)
if (ii(0) eq -1) then stop
;
ff2 = ff(ii)
ff2 = reverse(ff2)
break_file, ff2, dsk_log, dir, filnam, ext
dir2 = dir(uniq(dir))
filnam2 = str_replace(filnam+ext, '_001.fits', '*.fits')
ff3 = file_list(dir2, filnam2)
;
tr_summary_head, ff3, out, lst=lstfil, nofilename=qseq_val
;
ans0 = 0
if (lstfil eq '/tsw/dbase/cal/info/mhead_tab_seq_val.lst') then begin
    if (n_elements(ii) ne 1) then begin
	tbeep, 3
	print, 'WARNING: You selected more than one input filename series'
	print, 'WARNING: The output listing in this case would go to one file'
    end
    ;
    yesnox, 'Do you want to save in the official RUNS database?', ans0, 'Y'
    if (ans0) then begin
	dattim = strmid(filnam(0), 0, 13)
	descr  = strmid(filnam, 14, 999)
	descr = str_replace(descr, '_001', '')
	if (descr eq '') then descr = '_xxx'
	;
	outdir = '/tsw/dbase/data/runs'
	outfilnam = descr + '_' + dattim + '.seq_val'
	outfil = concat_dir(outdir, outfilnam)
	prstr, out, file=outfil
    end
end
;
if (ans0 eq 0) then begin
    yesnox, 'Do you want to save the output to file?', ans, 'N'
    if (ans) then begin
	input, 'Enter the output filename', outfil, 'tr_summary_head.txt'
	prstr, out, file=outfil
    end
end
;
yesnox, 'Do you want to print the file?', ans, 'N'
if (ans) then begin
    outfil = 'tr_summary_head.temp'
    prstr, out, file=outfil
    sprint, outfil, /land
end
;
end
