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:
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.
The %assign
directive declares and sets variables. In this instance, it holds a string filename identifier. GET_COMMAND_SWITCH() returns whatever string argument follows a specified TLC command switch. Note that uppercase is always used for built-in function names.
*** SYSTEMS AND BLOCKS IN RECORDFILE
" to read as
follows:
*** recordfile contains %<nbls> blocks in
%<
NumSystems> systems
" to:
*** recordfile %<inputfile> contains %<nbls> blocks in ...
%<NumSystems> systems
The "%< >
" operator causes variables to be evaluated, substituting their contents for the tagged expression. The ellipsis ("...
") at the end of the line indicates that the line is continued below, but prints without a line break.
%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.
![]() | Counting Blocks and Subsystems | Passing and Using a Parameter | ![]() |