File mttroot/mtt/bin/trans/abg2cmp_fig2txt artifact ef01106a85 part of check-in 324ec37f95


#! /bin/sh

### abg2cmp_fig2txt
##  Creates list of components contained in _abg.fig
## Copyright (C) 2002 by Peter J. Gawthrop

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Log$
  ## Revision 1.3  2002/12/06 22:12:28  geraint
  ## Removed unique option from sort
  ## - prevents multiple anonymous components from existing
  ## - duplicate named components are caught by rbg_fig2m.awk anyway
  ##
  ## Revision 1.2  2002/12/06 11:47:49  gawthrop
  ## Checks levels in fig file to extract genuine components
  ## Puts comments at top of cmp.txt file
  ##
  ## Revision 1.1  2002/12/01 14:54:39  gawthrop
  ## Replaces defunct abg2lbl_fig2txt
  ##
  ##
  ###############################################################

system=$1
infile=${system}_abg.fig
outfile=${system}_cmp.txt
date=`date`

echo Creating ${outfile}

header() {
    cat <<EOF
## List of components contained in system ${system}
## File ${outfile}
## Created by mtt on ${date}

EOF
}
get_valid_components()

{
gawk '
function modulo10(x) {
  return x-int(x/10)*10
    }
BEGIN{
  polyline = 2;
  text = 4;
  compound_object = 6;
  length_terminator=4;

}
{
  object = $1;
  zero_depth =  (modulo10($4)==0)&&(object==text);
  if (zero_depth) {
    print substr($NF,1,length($NF)-length_terminator)
  }
}' 

}

remove_port_labels() {
  grep -v '^\[.*\]$'
}

## Create header
header > ${outfile}

## Make list of components
get_valid_components < ${infile} |\
   remove_port_labels |\
   sort >> ${outfile}


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