#!/bin/bash
# getex : displays ECMC example files
# A.S. July 2004

if ( [ $# == 0 ] ) ; then  # print usage summary
 echo 'getex :  diplays example ECMC file(s)  (any files that can be listed with the lsex command)'
 echo '   syntax: getex filename  [filename2  filenameN]' 
 echo ' For more usage details type:   man getex '
 exit 0
fi

  SCEXDIR="$CSLIBDIR/ex"
  TUTDIR="$CSLIBDIR/tut/ex"
for i in  $* ; do
  #if [ test -f $SCEXDIR/$i 2> /dev/null ] ; then # Csound library score11
  if [ `ls $SCEXDIR/$i 2> /dev/null` ] ; then # Csound library score11 file
    echo " < Example score11 input file >> $i <<  : "
    cat $SCEXDIR/$i ;  shift ; 
  elif [ `ls $TUTDIR/$i 2> /dev/null` ] ; then # Csound tutorial score11 file
    echo "  < ESM Csound Library Tutorial score11 input file >>  $i << : "
         cat $TUTDIR/$i  ; shift
  elif [ `ls $PVCDIR/TKLAEXAMPLES/$i 2> /dev/null` ] ; then # Csound tutorial score11 file
   # Not needed:  echo "  < Example PVC script file >>  $i << : "
         cat $PVCDIR/TKLAEXAMPLES/$i  ; shift
  elif [ `ls $TURNKEY/vspace/X/$i 2> /dev/null` ] ; then # SMSS example
      echo "  ####  ECMC vspace example script file >>  $i << : ####"
         cat $TURNKEY/vspace/X/$i  ; shift

  elif [ `ls $SMSXDIR/$i 2> /dev/null` ] ; then # SMSS example
      # echo "  #  ECMC vspace example script file >>  $i << : "
         cat $SMSXDIR/$i  ; shift
 else
   echo "ERROR: No ECMC example file named -> $i <-  found. Quitting."
   echo '  getex syntax:      getex filename  [filename2  filenameN]' 
   exit 1
  fi
done
