File mttroot/mtt/bin/trans/struc_txt2m artifact 8e5a3e29dd part of check-in 66bb5feadf


#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: struc_txt2m

# Structure file - txt to m conversion
# P.J.Gawthrop April 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2001/03/19 02:28:52  geraint
## Branch merge: merging-ode2odes-exe back to MAIN.
##
## Revision 1.1.2.1  2001/03/06 03:52:15  geraint
## Put back struc_txt2m - required by mtt2sys.
##
###############################################################



# Inform user
echo "Creating $1_struc.m"

rm -f mtt_error

#Write some file headers
echo "function [input_name,output_name,state_name] = $1_struc" > $1_struc.m
echo "%% Structure file ($1_struc.m)" >> $1_struc.m
echo "%% Generated by MTT at `date`" >> $1_struc.m

cat  >> $1_struc.m <<EOF

## Default to null strings
 input_name = "";
 output_name = "";
 state_name  = "";
EOF



# This is the main transformation using awk
awk '
function header(what){
  print what "_name = [";
}

function footer(what){
  print "];";
}

BEGIN{
Which="";
apostrophe = "\047";
}
{
  if ($1!=Which) {
    if (Which!="") footer(Which);
    header($1);
  }
  print  apostrophe $4 "_" $3 apostrophe;
  Which = $1;
}
END{
  footer(Which)
}
'  SYSTEM=$1  < $1_struc.txt >> $1_struc.m 2>mtt_error.txt

# Now invoke the standard error handling.
mtt_error mtt_error.txt




MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]