You can initialize the value of a macro variable in your configuration file, and you can assign a value to a macro variable in the body of a macro definition:
Assign starting values to macro variables in configuration section [MacroVariables]. Omit the leading $$ when you specify the name. For example:
[MacroVariables] ; varname = value to use as literal replacement, can be in Macro Ini ; can also be set in any macro with <$$name=value>, settings persist ; until the end of the file, but are not stored in the .ini file. HdgCount = 000 HdgColor = blue
You can assign only literal values; you cannot assign a value that specifies a macro or another macro variable.
Place section [MacroVariables] in one (or more) of the following files, after any macro definitions:
Use any of the following forms to assign values to variables inside DITA2Go macros:
<$$varname = $$othername> <$$varname = (expr)> (See §37.6 Using expressions in macros) <$$varname = "quoted string even with \"double quotes\" in it"> <$$varname = 'quoted string using "single" quotes'> <$$varname = string with no quotes> <$$varname = 'x'> (Character literal)
The value of a character literal assigned to a macro variable is the ASCII value of the character. A character literal can be a character enclosed in single quotes, or any of the special cases listed in Table 37-4.
'\r' |
13 |
|
'\n' |
10 |
|
'' |
0 |
|
\' |
39 |
|
\\ |
92 |
Characters other than ' and \ that are preceded by a backslash are themselves. However, ' and \, without a backslash, are not themselves:
would be an empty string followed by an out-of-place ', thus 0 (zero) |
|
is invalid, and would probably become a string with a single quote, equivalent to "\'" |
When a string between single quotes contains more than two characters (or more than one when the first character is not a backslash), you do not have to escape double quotes within the string, a common JavaScript and HTML technique.
Assigning a value to a macro variable does not cause the value to appear in output. To display the value of an assignment, use as and a printf() format. For example, if the value of <$$myvar> is 0 (zero), the following expression displays the value 0001:
<$$myvar = ($$myvar + 1) as %0.4d>
See §37.6.3 Displaying expression results in output.
You can assign a value to a variable indirectly:
<$$myvar = "$$other"> <*$$myvar = 10>
This sequence results in assigning the value 10 to $$other rather than to $$myvar. See §37.6.7 Using indirection in expressions.
[Macros] ; MacroVarNesting = Yes (default, vars contain <>) ; or No (first > ends var) MacroVarNesting=Yes
This setting is provided solely to support old syntax in assignments. You used to use:
<$$myvar=<$$othervar>>
<$$myvar = $$othervar>
You need MacroVarNesting=Yes only if your macro variable assignments use the old syntax; the new syntax is always valid. Either way, you get the contents of the referenced right-hand variable, rather than its name.
Note: Macro variables cannot contain macros.