2.5 Replaceable Parameters

A special syntax is available for specifying values containing replaceable parameters. A replaceable parameter appears in a value as a number between braces, such as {0}. A replaceable parameter can be embedded within a string in a string table, or in other variables referenced with the VAR keyword. The replaceable parameter will be replaced with the appropriate value when the document is generated based on the parameters used in the template. For example, in a string table there could be an entry such as:

srchResults=You have {0} messages.

A template would refer to this string as follows:

{STRING srchResults {VAR Item.count}}

So that srchResults is the name of the string that should be added to the final document. {Item.count} is the parameter that replaces {0} in the string, Therefore, if Item.count had a value of 10, the resulting string would be:

You have 10 messages.

If there are replaceable parameters, the number found in the parameter refers to the position of the parameters in the template. {0} refers to the first replaceable parameter, {1} refers to the second parameter, etc.

# String Table entry:
# {0} is the first parameter in the template,
# {1} is the second parameter in the template,
# {2} is the third parameter in the template.
ThreeValues=Value 2 is {1}, value 1 is {0}, and value 3 is {2}.
{! Template usage }
{SET v1="One"}
{SET v2="Two"}
{SET v3="Three"}
{STRING threeValues {VAR v1} {VAR v2} {VAR v3}}

This example outputs the following:

Value 2 is Two, value 1 is One, and value 3 is Three.