#! /bin/csh -f
#
# script to make an author index for the pir library
#

echo "pirauthor.script Version 1.0"

set RM = "/bin/rm -f"
set SORT = sort

#
# LIBFILE is the name youve given to the library file
#
set LIBFILE1 = pir1.dat
set LIBFILE2 = pir2.dat
set LIBFILE3 = pir3.dat

pirauthor $LIBFILE1 pir1.list
if ( $status ) goto abort
pirauthor $LIBFILE2 pir2.list
if ( $status ) goto abort
pirauthor $LIBFILE3 pir3.list
if ( $status ) goto abort

# sort on entry name
${SORT} -u pir1.list pir2.list pir3.list >! author.sorted
if ( $status ) goto abort
${RM} pir1.list pir2.list pir3.list

# include entry numbers in the file
freetext2 author.sorted author.entry
if ( $status ) goto abort
${RM} author.sorted

# sort on text
${SORT} -b +2 author.entry >! author.sorted2
if ( $status ) goto abort
${RM} author.entry

# create the index
hitNtrg author.sorted2 author.trg author.hit 35
if ( $status ) goto abort
${RM} author.sorted2

exit 0

#
# Abort
#
abort:
echo "pirauthor.script: aborting due to serious error"
exit 2
