#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: struc_txt2tex
# Stucture file - text to TeX table conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################
# Inform user
echo "Creating $1_struc.tex"
rm -f mtt_error
#Write some file headers
echo "%% Structure file ($1_struc.txt)" > $1_struc.tex
echo "%% Generated by MTT at `date`" >> $1_struc.tex
# This is the main transformation using gawk
gawk '
function header(){
print "\\begin{tabular}{l|l|l}";
}
function footer(what){
print "\\caption{" what "}";
print "\\end{tabular}"
}
BEGIN{
Which=""
}
{
if ($1!=Which) {
if (Which!="") footer(Which);
header();
}
print $2, $3, $4;
Which = $1;
}
END{
footer(Which)
}
' < $1_struc.txt >> $1_struc.tex 2>mtt_error.txt
# Now invoke the standard error handling.
#mtt_error mtt_error.txt