#!/bin/csh -f
#    getcsfunc ( getfunc )

if ($#argv == 0) then
   echo "getfunc syntax:   getfunc   funcfile1   [funcfil2]  [funcfileN]"
   echo ' where the "funcfile" arguments are the names of function'
   echo ' definition files. To obtain a list of available Library'
   echo ' function definition files, type:     lsfunc'
   exit 1
endif

/bin/rm -f ~/.tmpfile >& /dev/null
set FUNCDIR = "$CSLIBDIR/funcs"
cd $FUNCDIR
set GEN1DIRS = `ls GEN1`
foreach x (`echo $GEN1DIRS`)
  echo GEN1/$x >> ~/.tmpfile
end
set ALLDIRS = `echo GENERAL; cat ~/.tmpfile`
/bin/rm -f ~/.tmpfile >& /dev/null

foreach i ($argv)
   set FOUND = NO
   foreach DIR (`echo $ALLDIRS`)
#echo DIR = $DIR and FOUND = $FOUND
     if ($FOUND == NO) then
        if (-e $DIR/$i) then
              cat $DIR/$i
              set FOUND = YES
         endif
      endif
   end
   if ($FOUND == NO) then
      echo "   There is no Library function file called >> $i <<"
      echo "    To obtain a list of available Orchestra Library functions type:"
      echo "              lsfunc"
      exit 1
   endif

end
