;+
;
; NAME: 
;       FS_PRINT
;
; 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 fs_print
; 
; Print accumulated Batse flare search data values for time interval plotted
; by Fsplot.
;
; Shelby Kennard                                   15April1991
;
; Mod. by akt 5/30/91 to call pprint instead of printing to a file and then
; doing a type/page.
;
; Mod by Amy Skowronek 6/28/94 to show detector id's as 0-7 rather than 1-8.
; Mod by AES 7/11/94 to call page_print instead of pprint.
;*****************************************************************************
@fscom.pro
@fs_saveplot
;
; First check whether any data has been accumulated (sec_arr won't be
; defined if no data has been accumulated.)
s = size(sec_arr)
if s(1) eq 0 then begin
   print,'No BATSE data has been accumulated.'
   goto,getout
endif
;
openw, lun, 'fs_print.out', /get_lun
;
abort = 0
count = 0   ; initialize counter that counts lines printed on screen
;
page_print, outprint, count, lun,' '
page_print, outprint, count,  lun, $
   format='("BATSE Flare Plot",t42,"Current time:",a)',$
   strmid(atime(sys2ut(0),/hxr),0,14)
page_print, outprint, count,  lun, ' '
page_print, outprint, count,  lun, ' '

case 1 of
type_sav le 1: page_print, outprint, count, lun, 'Data type:  DISCLA'
type_sav eq 2: page_print, outprint, count, lun, 'Data type:  CONTINUOUS'
type_sav eq 3: page_print, outprint, count, lun, 'Data type:  DISCSP'
else:
endcase
num_pt = n_elements(out_arr)
page_print, outprint, count,  lun, $
   format='("Start time: ",a,t42,"End time: ",a)',atime(sec_arr(0),/hxr),$
   atime(sec_arr(num_pt-1),/hxr)
;
if type_sav eq 3 then area = 127. else area = 2025.
page_print, outprint, count,  lun, $
   format='("Detector: ",i2, t18, "Eff. Area (cm**2): ",t38 ,f7.2)', $
   det_sav(0), area*cos_sav(0)
if n_elements(det_sav) gt 1 then begin
   for i=1,n_elements(det_sav)-1 do begin
      page_print, outprint, count,  lun, $
         format='(t11,i2, t38 ,f7.2)', det_sav(i), 2025.*cos_sav(i)
   endfor
endif
page_print, outprint, count,  lun, format='("Channels: ",16i2)',ch_sav
;
page_print, outprint, count,  lun, format='("Number of samples averaged: ",i2)', $
       sam_av_sav
;
; Print time and data value for each point.
;
page_print, outprint, count,  lun, ' '
page_print, outprint, count,  lun, ' '
page_print, outprint, count,  lun, $
   format='("Data interval mid-point time",t45,"Data value (counts/sec)")'
page_print, outprint, count,  lun, ' ' 
;
for i=0,num_pt-1 do begin
  t = sec_arr(i)
  if (xmax gt 0.0) and (t gt xmax) then goto,done
  if t ge xmin then page_print, outprint, count,  lun, abort = abort, $
     format='(a,t43,g13.6)', atime(sec_arr(i),/hxr), out_arr(i)
     if abort then goto,done
endfor
;
done:
close, lun
;
; Send output to specified device terminal or laser print.
;
if outprint eq 1 then begin
   spawn,'print/setup=port fs_print.out'
endif 
print,''
print,'This information is saved in file ', findfile('fs_print.out')
;
mailfile,'fs_print.out'
;
getout:
return&end
