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

Properties
Property
Description
Format
The formatting rule for variable reference:
  • Index
    . An index number that identifies an input variable. For every
    {index}
    placeholder in the formatting rule, a new field that indicated the source appears.
  • Alignment
    . An integer that represents the number of characters of the source value formatted according to the rule.
  • Format
    . The formatting to be applied to input variables.
    The format placeholder accepts a subset of the values required by the .NET Framework notation for the
    String.Format
    method. Placeholders must use the syntax
    {index,alignment:format}
    .
Dynamic link mode
Read
Read direction for dynamic link icon
Read from the source node to the parent.
Default for dynamic links defined in NetLogics.
Write
Write direction for dynamic link icon
Write from the parent to the source node.
Read/write
Read and write direction for dynamic link icon
Read from the source node to the parent and write from the parent to the source node.
Default for dynamic links created in
FactoryTalk Optix Studio
UI.
Dynamic link
One or more variables identified by:
{
index_number
}
placeholder
Progressive integer equal to or greater than zero. For example,
{1}
{#
placeholder_identifier
}
placeholder
String prefixed with
#
. For example,
{#speed}
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 link
    Mode
    of the converter must be
    Read/Write
    .
  • The
    Format
    field 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
Visual representation of a string formatter configuration, showing a message input, a
            format field with the text "Apply value: {0}?", and a dynamic link referencing a UI text
            box value.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal