#!/data/oir/IRAF2.16.1/bin.linux64/cl.e -f
# This script runs RVSAO.CONTPARS from a Unix command line
# Replace the path in the first line with one appropriate to your machine
# November 13, 2020
# By Jessica Mink

string uprm, hm, tempcom

# Set machine type appropriately
set arch=".linux64"

# Set the terminal type.
if (envget("TERM") == "sun") {
    stty gterm
} else if (envget("TERM") == "xterm") {
    stty xterm
} else if (envget("TERM") == "network") {
    stty vt100
} else {
    stty xterm
}

# Set the IRAF home and parameter directories
if (defvar("irafhome")) {
    hm = envget("irafhome")
    i = strlen(hm)
    if (substr(hm, i, i) == "/")  
        set (home = hm)
    else
        set (home = hm // "/")
    set uparm = "home$uparm/"
    }
else {
    hm = envget ("HOME")
    set (home = hm // "/IRAF/")
    set uparm = "home$uparm/"
    }

if (defvar("UPARM")) {
    uprm = envget("UPARM")
    i = strlen(uprm)
    if (substr(uprm, i, i) == "/")  
        set (uparm = uprm)
    else
        set (uparm = uprm // "/")
  }

# Set the user name which may appear on graphical output
if (envget("USER") != "") {
    set user = envget("USER")
    }

if (args == "help") {
    tempcom = mktemp ("tempcontpars")
    print ("help contpars", > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }

# Edit contpars parameters using epar
else if (args == "epar") {
    tempcom = mktemp ("tempcontpars")
    print ("rvsao motd-\nepar contpars", > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }

# Dump contpars parameters using dpar
else if (args == "dpar") {
    tempcom = mktemp ("tempcontpars")
    print ("rvsao motd-\ndpar contpars", > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }

# List contpars parameters using lpar
else if (args == "lpar") {
    tempcom = mktemp ("tempcontpars")
    print ("rvsao motd-\nlpar contpars", > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }
else {
    print ("CONTPARS:  Set parameters for XCSAO and EMSAO continuum removal")
    print ("usage: contpars help  for IRAF help")
    print ("       contpars dpar  to dump parameters")
    print ("       contpars epar  to edit parameters")
    print ("       contpars lpar  to list parameters")
    }

logout

# Mar 31 2009	New shell command line script
# Nov 13 2020	Switch from IRAF 2.14.1 to IRAF 2.16.1
