#!/bin/csh
### From Record Number, find out the Flux

#### Check the number of arguments in the correct range.
if (($#argv == 0) || ($#argv > 1)) then
    echo "Usage: $0 record_number"
    echo "       Print out the spectrophotometry for one star from file(s):"
    exit 1
endif

set cat = cat
set file = suppl
if (-r $file.gz) then
    set cat = gzcat
endif
if (-r $file.Z) then
    set cat = zcat
endif
echo ""
$cat $file | gawk "NR==$1"'{\
    printf("{\\Large\\bf Spectrophotometry of HD %s",substr($0,13,6)); \
    print "\t(from " substr($0,20,2) " spectra)}\\begin{verbatim}" ; \
    print " (nm)\t  Flux    \tErr%"; \
    l = 135; j=1125; for (i=45; i<1125; i += 9) { \
     printf("%4d.0\t%s\t%s\n", l, substr($0,i,9), substr($0,j,3)) ; \
     l += 1 ; j += 3} exit }' 
echo '\end{verbatim}'

exit 0
