#! /bin/sh

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

# Bourne shell script: reps_txt2tk
# Creates tk/tcl file for xmtt.
# Copyright (c) P.J.Gawthrop, 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  1999/03/09 00:03:19  peterg
## Revisions for xmtt
##
## Revision 1.1  1998/10/20 08:13:14  peterg
## Initial revision
##
###############################################################


# Create reps menu
awk '{
# Important representation?
 if (index($1,"*")) {
    rep=substr($1,1,length($1)-1);
    printf("\n# Menus for representation %s\n", $1)
    printf(".rep.rep add  cascade -label \"%s\" -menu .rep.rep.%s\n", rep, $1);
    printf("menu .rep.rep.%s\n", $1);
    for (i=2;i<=NF;i++) {
      printf(" set mtt {mtt $args $system %s %s} \n", rep, $i); 
      printf(".rep.rep.%s add  command -label  \"%s\" ", $1, $i);
      printf(" -command  \"exec echo $mtt &; exec $mtt &\" \n"); 
   }
 }
 else {
    rep = $1;
    printf("\n# Menus for representation %s\n", rep)
    printf(".repall.repall add  cascade  -label \"%s\" -menu .repall.repall.%s\n", rep, rep);
    printf("menu .repall.repall.%s\n", rep);
    for (i=2;i<=NF;i++) {
      printf(" set mtt {mtt $args $system %s %s} \n", rep, $i); 
      printf(".repall.repall.%s add  command -label  \"%s\" ", rep, $i);
      printf(" -command  \"exec echo $mtt &; exec $mtt &\" \n"); 
   }
 }
}'









