;+
;
; NAME: 
;       DO_FDBFILES
;
; PURPOSE:
;
;
; CATEGORY:
;       BATSE
;
; CALLING SEQUENCE:
;
;
; CALLS:
;	none
;
; INPUTS:
;       none explicit, only through commons;
;
; OPTIONAL INPUTS:
;	none
;
; OUTPUTS:
;       none explicit, only through commons;
;
; OPTIONAL OUTPUTS:
;	none
;
; KEYWORDS:
;	none
; COMMON BLOCKS:
;	none
;
; SIDE EFFECTS:
;	none
;
; RESTRICTIONS:
;	none
;
; PROCEDURE:
;	none
;
; MODIFICATION HISTORY:
;
;-
pro do_fdbfiles
;
; Writes FDB files for flares between first and last. 
; 
; Kim Tolbert 3/3/92
;
;****************************************************************************
!quiet = 1
;
@fscom
@fs_saveplot
@fs_saveaccum

hxrbs_format, old_format = old_time_format

; get symbols for first and last flare to do and convert to numbers (by *1)
first = get_symbol("first")*1
last = get_symbol("last")*1
;
print, ' '
print, '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
print, 'Writing FDB files for flares ', first, ' - ', last
print, ' '
;
if (size(seconds))(0) eq 0 then fsdef,x
dd_type = 0 ; set input database type to FDB
;
;
for iflare = first,last do begin
   read_flare, iflare, flare_rec, error=error
   if error then goto,next
   write_fdb, iflare, flare_rec.start_secs, $
              flare_rec.start_secs+flare_rec.duration, $
              [flare_rec.bkg1_start_secs,flare_rec.bkg2_start_secs], $
              [flare_rec.bkg1_start_secs+flare_rec.bkg1_duration, $
               flare_rec.bkg2_start_secs+flare_rec.bkg2_duration]
   next:
endfor
;
print,' '
print, '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
print, 'Completed FDB files for flares ', first, ' - ', last
print,' '
;
getout:
;
if old_time_format eq 'YOHKOH' then yohkoh_format
return&end
