String formatter
Modify the formatting of one or more values according to a customizable rule.
TIP:
You can use the string formatter to:
- Link multiple strings in a series.
- Add characters before or after a value, if the value of the source variable is numeric.
- Apply numeric formatting, such as decimal places or float rounding. See String formatter data types .
- Format and parameterize SQL queries to use in database objects. See String formatter SQL query examples .
Input
Property | Description |
|---|---|
Format | The formatting rule for variable reference:
|
Dynamic link mode |
|
Dynamic link | One or more variables identified by:
TIP:
Use any combination of placeholders in any order. Use any number of placeholders in the expression.
This property is available only for converter
instances and not converter types. |
Formatting
Nest placeholders
{index,alignment:format}
to dynamically change the
formatting of the displayed data. For example: - {0:f{1}}
- The variable value linked with{1}defines the number of decimal places.
- {0:{1}{2}}
- The variable value linked with{1}defines the numeric data type.
- The variable value linked with{2}defines the number of decimal places.
- {0,{1}:{2}{3}}
- The variable value linked with{1}defines the alignment.
- The variable value linked with{2}defines the numeric data type.
- The variable value linked with{3}defines the number of decimal places.
Path formatting
Consider these path formatting capabilities:
- To format a string as a file path, you can use this syntax:{index,alignment:.filepath}
- Input
- ns=9;%PROJECTDIR%/Logo.svg
- Output
- C:\Users\UserName\AppData\Local\Rockwell Automation\FactoryTalk Optix\Emulator\Projects\ProjectName\ProjectFiles\Logo.svg
- To format a string as a URI, you can use this syntax:{index,alignment:.uri}
- Input
- ns=9;%PROJECTDIR%/Logo.svg
- Output
- file:///C:/Users/UserName/AppData/Local/Rockwell Automation/FactoryTalk Optix/Emulator/Projects/ProjectName/ProjectFiles/Logo.svg
- To format a part of a path, you can use this syntax:file:///C:/Reports/Report.{0}.pdf
Use inverse formatting to modify a formatted value at runtime to replace the value with a
new value that the application displays with the same formatting at runtime. The inverse
formatting feature requires the following settings to operate correctly:
- The dynamic linkModeof the converter must beRead/Write.
- TheFormatfield must have only one placeholder or source. The placeholder can have a suffix and/or prefix and be set with a format string such as{0:n}.
Output
The string entered in the
Format
property, based on the formatting rules with values in place of the placeholder or placeholders.Example
Instance of a string formatter

Provide Feedback


