FB_BA_DecorString

Function block for creating formatted, decorated text. This function block allows you to progressively construct strings by combining multiple formatted values with a configurable separator, prefix, and postfix. This is particularly useful for creating output strings with multiple parameters.
Syntax
FUNCTION_BLOCK FB_BA_DecorString
VAR_INPUT CONSTANT
sSeparator : STRING(5) := ', ';
sPrefix : STRING(5) := '(';
sPostfix : STRING(5) := ')';
END_VAR
VAR_OUTPUT
sOutput : T_MaxString;
nCount : UINT;
bResult : BOOL;
END_VAR
END_FUNCTION_BLOCK
Inputs CONSTANT
Name | Type | Description |
|---|---|---|
sSeparator | STRING(5) | Separator between the decorations. Default: |
sPrefix | STRING(5) | Prefix at the beginning of the output. Default: |
sPostfix | STRING(5) | Postfix at the end of the output. Default: |
Outputs
Name | Type | Description |
|---|---|---|
sOutput | The formatted output string with all added decorations. | |
nCount | UINT | Number of decorations added. |
bResult | BOOL | Success flag for formatting. |
Example of use
Reset();
AddDecor1('value1: %d/%d', F_UINT(25), F_UINT(100));
AddDecor1('value2: %s', F_STRING('my string'));
Finish();Result: “(value1: 25/100, value2: my string)”
Methods
Name | Definition location | Description |
|---|---|---|
Local | Adds formatted strings for decoration with 0–5 arguments (AddDecor–AddDecor5). | |
Local | Resets all outputs and the counter. | |
Local | Finalizes the decoration and combines the prefix and postfix. |
Properties
Name | Type | Access | Definition location | Description |
|---|---|---|---|---|
IsEmpty | BOOL | Get | Local | Indicates whether no decorations have been added. |