if .not.exist(all) @ all-create
!
begin procedure save_all
  for i 1 to pro%narg
    @ save_one 'pro%arg[i]'
  next
end procedure
!
begin procedure save_one
  say "let " "&1 " /format A4 A16 /noadv
  define integer r t s
  let t typeof(&1) 
  let r rank(&1) 
  let s size(&1) 
  !
  if (t.gt.0) then
    if (r.eq.0) then
      say """"'&1'"""" /format A A A /noadv
    else
      for k 1 to s
        say """"'&1[k]'""" " /format A A A /noadv
      next
    endif
    say " &2" /forma A A
  else
    if (t.eq.type_logi) then        ! It is a logical
      say &1 " &2" /format L2  A    ! Writes T or F
! code to write YES or NO
!      if (r.eq.0) then
!        say '&1' /format A4 /noadv
!      else
!        for k 1 to s
!          say '&1[k]' /format A4 /noadv
!        next
!      endif
!      say " &2" /forma A 
    else if ((t.eq.type_inte).or.(t.eq.type_long)) then
      say &1 " &2" /format (X,I0)  A 
    else if ((t.eq.type_real).or.(t.eq.type_dble)) then
      say &1 " &2" /format (X,G0)  A 
!    else ! Generic solution, normally for I, R, D, and even Char
!      say &1 " &2" /format (X,G0)  A 
    endif
  endif
end procedure save_one
!
! Create the all-memory.ima script
sic output all-memory.ima
!
say "if .not.exist(all) @ all-create"
say "let T .true. /new logical"
say "let F .false. /new logical"
say "!"
say "!--------------------------------------"
say "! Parameters that change the list of data products"
say "!"
if exist(linedb%dbin) then
  say "catalog " /format A /noadv
  for i 1 to size(linedb%dbin)
    say """"'linedb%dbin[i]'""" " /format A A A /noadv
  next
  say " ! Spectral line catalog " /format A
endif
if (exist(redshift)) then
  say "if .not.exist(redshift) define real redshift /global"
  @ save_one redshift "     ! Source redshift for line identification"
else
  say "! No Redshift - Using rest frequencies for line identification"
endif
@ save_one all%telescope "    ! Telescope used to obtain the data" 
!
@ save_one all%filter   "    ! UV tables to be selected"
say  "!    Data with resolution coarser than all%minfres will be Continuum only"
@ save_one all%minfres  "    ! (in MHz) "
say "!"
say "!---------------------------------------"
say "! All-in-One tools characteristics      "
say "!   that affect the content of data products"
! 
@ save_one all%mode     "    ! Pipeline Mode"
@ save_one all%itime    "    ! Time averaging constant" 
@ save_one all%drop     "    ! Channels dropped at edge"
say "!     Velocity range and Spectral resolution around each spectral line"
@ save_one all%range    "    ! (in km/s) "
@ save_one all%resample "    ! Spectral Resampling of UV Tables"
!
say "!"
say "! Data structure -  usually unchanged"
@ save_all all%maps all%raw all%self all%tables all%uvfits
@ save_one all%prefix_self "    ! Prefix for self-calibrated data"
!
say "!---------------------------------------"
say "! Self-Calibration parameters - usually guessed from Telescope"
say "!"
@ save_one all%minband  "    ! Minimum bandwidth (MHz) for self-calibration"
@ save_one all%ampli_niter "/resize    ! Number of retained Clean components for Amplitude "
@ save_one all%ampli_times "/resize    ! Integration time for Amplitude"
@ save_one all%phase_niter "/resize    ! Number of retained Clean components for Phase" 
@ save_one all%phase_times "/resize    ! Integration time for Phase"
@ save_one all%collect "     ! Flagging threshold in solutions"
@ save_one all%combine "     ! Combine Phase solutions into a Delay solution"
!
! UV_MAP characteristics
say "!---------------------------------------"
say "! UV_MAP characteristics"
say "!"
@ save_one all%restore   "   ! Use UV_RESTORE in Imaging process ?"
@ save_one map_center 
@ save_one BEAM_STEP     "   ! Number of channels per beam"   
!
@ save_all MAP_CELL         MAP_CONVOLUTION  MAP_FIELD 
@ save_all MAP_POWER        MAP_PRECIS       MAP_ROBUST       MAP_ROUNDING     MAP_SIZE 
@ save_all MAP_TAPEREXPO    MAP_TRUNCATE     MAP_UVTAPER      MAP_UVCELL       
!
! CLEAN characteristics
say "!---------------------------------------"
say "! CLEAN characteristics"
say "!"
@ save_one METHOD           " ! Cleaning method"
@ save_one BEAM_SIZE        " ! Selected Clean beam shape"
@ save_one CLEAN_STOP       " ! CLEAN Stopping criterium"   
@ save_all CLEAN_ARES       CLEAN_FRES       CLEAN_GAIN       CLEAN_INFLATE    CLEAN_NCYCLE
@ save_all CLEAN_NGOAL      CLEAN_NITER      CLEAN_NKEEP      CLEAN_POSITIVE   CLEAN_SEARCH
@ save_all CLEAN_SIDELOBE   CLEAN_SMOOTH     CLEAN_SPEEDY     CLEAN_TRUNCATE   CLEAN_WORRY
@ save_all BLC    TRC
say "!"
sic output
!

