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

string uprm, hm, tempcom, templist

# 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/"
    uprm = "home$uparm/"
    }
else {
    hm = envget ("HOME")
    set (home = hm // "/IRAF/")
    set uparm = "home$uparm/"
    uprm = "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 == "") {
    print ("LISTSPEC:  List wavelength(s) and pixel value(s) for a spectrum")
    print ("usage: listspec linefile specfile [other arguments]")
    print ("       listspec help  for IRAF help")
    print ("       listspec dpar  to dump parameters")
    print ("       listspec epar  to edit parameters")
    print ("       listspec lpar  to list parameters")
    print ("       listspec relearn to relearn parameters")
    }
else if (args == "help") {
    tempcom = mktemp ("templistspec")
    print ("help listspec", > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }

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

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

# Dump listspec parameters using dpar
else if (args == "relearn") {
    tempcom = mktemp ("templistspec")
    print ("rvsao motd-\nrelearn (\"listspec\")", > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }

# List listspec parameters using lpar
else if (args == "lpar") {
    tempcom = mktemp ("templistspec")
    print ("rvsao motd-\nlpar listspec", > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }

# Execute listspec using the arguments on the command line
else {
    tempcom = mktemp ("templistspec")
    printf ("rvsao motd-\nlistspec %s\n", args, > tempcom)
    cl (< tempcom)
    delete (tempcom)
    }
logout

# Mar 31 2009 New shell command line script

# Feb 22 2010	Add relearn option
#
# Nov 13 2020	Switch from IRAF 2.14.1 to IRAF 2.16.1
