! REFORMAT - changes the data format of an existing MIDAS file
! @author Jeff Schoen

startmacro fn:in fn:out s:oform

status in format=iform                         ! get input format
sedit iform itype range 1 1
sedit oform otype range 1                      ! output type + rest of string

if otype eqs "*" then                          ! form output format (no R*08 though)
  sedit iform itype range 1 1
  sedit oform oform subs "*" "^itype"
endif

invoke oform=this.args.testformat(oform,"")

if iform eqss "S" and oform eqss "C" then      ! real to complex
  switch "TAPS" taps get 127
  firhlbrt tmphlbrt taps bh92
  fdfilter in tmphlbrt out{form=oform} /pad /mux

elseif iform eqss "C" and oform eqss "S" then  ! complex to real
  demux in out{form=oform}

else                                           ! rep only
  noop in out{form=oform}
endif

endmacro