Target Language Compiler | ![]() ![]() |
Interpreting Records
Here is the output from a TLC program script that reads guide.rtw
, interprets its records, manipulates field data, and formats descriptions, which are directed to the MATLAB command window:
Using TLC you can: * Directly access any field's value, e.g. %<Top.Date> -- evaluates to: "21-Aug-2008" * Assign contents of a field to a variable, e.g. "%assign worker = Top.Employee.FirstName" worker <- Top.Employee.FirstName = Arthur * Concatenate string values, e.g. "%assign worker = worker + " " + Top.Employee.LastName" worker <- worker + " " + Top.Employee.LastName = "Arthur Dent" * Perform arithmetic operations, e.g. "%assign wageCost = Top.Employee.PayRate * Top.Employee.Overhead" wageCost <- Top.Employee.PayRate * Top.Employee.Overhead <- 11.5 * 1.78 = 20.47 * Put variables into a field, e.g. "%assign Top.Employee.GrossRate = wageCost" Top.Employee.GrossRate <- wageCost = 20.47 * Traverse lists of values, e.g. "%assign projects = Top.Project[0].Name + ", " + Top.Project[1].Name..." "+ ", " + Top.Project[2].Name" projects <- Top.Project[0].Name + ", " + Top.Project[1].Name + ", " + Top.Project[2].Name = Tea, Gillian, Zaphod * Traverse and manipulate list data via loops, e.g. - At top of Loop, Project = Tea; Difficulty = 3 - Bottom of Loop, i = 0; diffSum = 3.0 - At top of Loop, Project = Gillian; Difficulty = 8 - Bottom of Loop, i = 1; diffSum = 11.0 - At top of Loop, Project = Zaphod; Difficulty = 10 - Bottom of Loop, i = 2; diffSum = 21.0 Average Project Difficulty = DiffSum / Top.NumProjects = 21.0 / 3 = 7.0
This "presentation" of guide.rtw
was produced by invoking the Target Language Compiler from the MATLAB command window, executing a script called read-guide.tlc
. Do this yourself now, by following these steps:
tlctutorial
/
guide
to your working directory.
cd
to /guide
within your working directory
guide.rtw
with the TLC script read-guide.tlc
by typing the following command:
-r
switch.
-v
switch (for verbose) is needed to direct output to the command window, unless the TLC file handles this itself.
![]() | Structure of Record Files | Anatomy of a TLC Script | ![]() |