#!/bin/ksh

# added skip & end flags # & !

# fitalot takes as input a file that is a list of slist files & an rlist file (confused?)
# Calls fitbn with each slist rlist file combo in succession 

# usage fitalot flist

flist=$1

#rm -f l.alot
exec 9< $flist

while read -u9 sl #rl  #atm
do

	case $sl in
	
	  \!* )
			print "fitalot : END record in <$flist> file reached ...exiting"
			break
			;;

	  \#* )
			print "fitalot : SKIP record in <$flist> file reached ...continue"
			continue 
			;;
	esac		# end case
  
    print "  Processing spectra list file: $sl" # $rl."
    print "    Calling fitbn ${sl}"

    fitbn $sl 0 #$rl #$atm
     
    rc=$?
    if(( $rc != 0 ))
    then
       print -R 'fitalot : Error in fitbn return code : ' ${rc}
       print -R ' Called : fitbn' ${sl} #$rl
       exit 1
    fi   
    #print " Call lR..."
    #lR Results
    #cat list.out >>l.alot

    done
 
exec 9<&-

exit 0