pro rawdump,x
;
;
;********************************************************************
!quiet = 1

common dumpcom, usefdb, dd_open, dd_type, sec_st, sec_to, sec_en, det_arr, $
  prcounts, prposition, prhouse, outprint

hxrbs_format, old_format=old_time_format
;
; Set defaults for operator communications.
;
checkvar, dd_type, 1
; 
; If sys$login = [ANNE] set DISCLA file type to BDB, otherwise FDB
;test = trnlog("sys$login",trans,/full)
;if strpos(trans(0), 'ANNE') gt 0 then usefdb = 0 else usefdb = 1
test=getenv('USER')
if test eq 'ANNE' then usefdb = 0 else usefdb = 1
;
if (size(dd_open))(2) eq 8 then begin
   find_dbfile,dd_open.filename,0,dd_open, dd_type, sec_st, sec_to, sec_en
   sec_to = 10.    ; seconds. 
   sec_en = sec_st + sec_to
endif else begin
   sec_st = 0.d0
   sec_to = 10.d0
   sec_en = sec_st + sec_to
endelse

det_arr = [0,1,2,3,4,5,6,7]
prcounts = 1
prposition = 1
prhouse = 1
outprint = 0 ; default is output to terminal
;
; Print operator communications on screen.
;
listoc = 1
op_com:
rawdumpoc,cmnd,listoc
;
; Determine command specified and act accordingly.
;
case 1 of
cmnd eq 'DUM': begin
  if (size(dd_open))(0) eq 0 then begin
    print,'Please set an input file before attempting to dump.'
    listoc = 1
    goto,op_com
  endif

  if (dd_open.type eq 0) and (dd_type gt 1) then begin
     print,'Cannot dump CONT or DISCSP data corresponding to a BDB file.'
     print,'You must first open a DISCLA FDB file for the flare you want.'
     goto, op_com
  endif

  if sec_en le sec_st then begin
    print,'Error--end time is less than or equal to start time, please correct.'
    goto,op_com
  endif
  ascii_raw
  if outprint eq 1 then begin
     spawn,'print/setup=port batse_raw.out'
  endif 
end
;
cmnd eq 'FIL': begin
  filelist, dd_type 
end
;
cmnd eq 'HEL': begin
   helpname  = 'help_rawdump.txt'
   helpfile=loc_file(path=[curdir(), path_dir('batse'),'BATSE_DATA'],helpname) 
   if helpfile ne '' then read_seqfile, morebf, helpfile else print,'Unable to find '+helpname
   more, morebf
   mailfile, helpfile
end
;
cmnd eq 'PRI': begin
  print,' '
   print, $
 'NOTE: If you haven''t issued the Dump command yet, Print prints the dump'
   print, $
 'file resulting from the last dump made on this account.'
   print,' '
   case outprint of
      0: spawn,'type/page batse_raw.out'
      1: spawn,'print/setup=port batse_raw.out'
      else:
   endcase
;
   mailfile,'batse_raw.out'
end
;
else: goto,getout ; Command is exit.
;
endcase
;
goto,op_com
;
getout:
;
;
dd_close, dd_open
;
if old_time_format eq 'YOHKOH' then yohkoh_format
return&end