
;+
; PROJECT:  SDAC
;	
; NAME: 
;       DO_EVENTLISTS
;
; PURPOSE:  
;	DO_EVENTLISTS creates the YYMMDD.EVENTS files on BATSE_EVENTS containing
;           all events catalogued on the given day.  
;
; CATEGORY:
;       BATSE
;
; CALLING SEQUENCE:
;	DO_EVENTLISTS, Firstday, Lastday
;
; CALLS:
;	none
;
; INPUTS:
;   firstday - (input) string containing first day to create file for in
;              the format '91/4/19'
;   lastday - (input) string containing the last day to create file for in
;             the fornat '91/4/25'
;       none explicit, only through commons;
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       none explicit, only through commons;
;
; OPTIONAL OUTPUTS:
;	none
;
; KEYWORDS:
;	none
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	A file, BATSE_FLARES.out, is renamed to yymmdd.events to BATSE_EVENTS
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	none
;
; MODIFICATION HISTORY:
;
; Kim Tolbert 8/15/91
;	Version 2, RAS, 3-apr-1997
;
;-
pro do_eventlists, firstday, lastday
!quiet=1
;
@flistcom

hxrbs_format, old_format=old_time_format
;
;
; batse_read_cat will read the catalog into common flare_cat
batse_read_cat
;
outprint = 1 ; set output to printer so it will be written on a file
             ; and not on terminal, but we won't actually print file
;
sec_st = anytim(/sec, firstday)
sec_en = sec_st + 86400.
;
nextday:
flare_select, good  ; find flares within sec_st and sec_en
parse_atime, sec_st, year=year, month=month, day=day, /string
evfile = year + month + day + '.events'
print,'Working on ' + evfile 
;
if good(0) eq -1 then begin
   openw, lun, concat_dir((chklog('BATSE_EVENTS'))(0),evfile), /get_lun
   printf, lun, 'No BATSE flares cataloged on ' + anytim(sec_st,/date,/hxrbs)
   print, 'No BATSE flares cataloged on ' + anytim(sec_st,/date,/hxrbs)
   close, lun & free_lun, lun
endif else begin
   flare_list, good
   spawn, 'copy/lo BATSE_FLARES.out ' + concat_dir('BATSE_EVENTS' , evfile)
endelse
;
sec_st = sec_en
sec_en = sec_st + 86400.
if sec_st gt anytim(/sec, lastday)+5. then goto,getout
goto,nextday
;
getout:
;
if old_time_format eq 'YOHKOH' then yohkoh_format

end
