Variable References

Return to Introduction  Previous page  Next page

Variable values can be retrieved by using a reference of the form:


where <name> can be a previously defined variable.

Variable references can be used in one of the following ways:

·As part of a macro, such as the argument to a function macro
·As a term in a variable definition
·As a direct substitution of the variable value into the output.

Note: It is legal to reference a variable before it is defined. In this case, the variable is assumed to contain an empty string value: ""


Using variables as part of a macro. The following is an excerpt from the default C++ ClassNotes template.

$wrapLen = %genOptWrapComment%

$style = %genOptCPPCommentStyle%


%if $style == "XML.NET"%





Define variables to store the style and wrap length options.

Reference to $style as part of a condition.

Reference to $wrapLen as an argument to function macro.


Using variable references as part of a variable definitions:

$foo = "foo"

$bar = "bar"


$foobar = $foo + $bar

Define our variables.

$foobar now contains the value foobar.


Substituting variable values into the output



class %className%$bases

Store the result of the ClassInherits template in $bases.

Now output the value of $bases after the class name.