Target Language Compiler    

Listing Block Names

Because you might want to itemize a model as well as to count how many blocks it contains, let's add TLC code that causes the name of the input file and the names of its blocks to be printed in the listing. To obtain the input filename, we use a built-in TLC function. For referencing block names, we invoke a TLC library function:

  1. Open listrtw1.tlc in your editor and save it as listrtw2.tlc. Be sure to change the argument to addincludepath to point to matlabroot/ on your system.
  2. To enable your program to access the input filename from the command line, do the following three things:
    1. Below the line %selectfile STDOUT, add a new line:
      • %assign inputfile = GET_COMMAND_SWITCH ("r")
        
    1. Change the line "*** SYSTEMS AND BLOCKS IN RECORDFILE" to read as follows:
    1. Change the line "*** recordfile contains %<nbls> blocks in %<NumSystems> systems" to:
  3. To report the name of each block as it is iterated:
  1. Below the line "%assign nbl = nbl + 1" add a new statement:

    The TLC library function LibGetFormattedBlockPath returns the full pathname string of a block without any special characters suitable for displaying the block name on a single line. TLC substitutes the returned value for the bracketed expression. Source code for the function is found in utillib.tlc, which is that library had to be included in the TLC script.

  1. Save listrtw2.tlc and execute it with
  1. The output is a report of block names grouped by subsystem (see listing in the next section, Passing and Using a Parameter).


  Counting Blocks and Subsystems Passing and Using a Parameter