FB_BA_DecorString

FB_BA_DecorString 1:

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

FB_BA_DecorString 2: Inputs CONSTANT

Name

Type

Description

sSeparator

STRING(5)

Separator between the decorations. Default: , (comma followed by a space).

sPrefix

STRING(5)

Prefix at the beginning of the output. Default: ( (opening parenthesis).

sPostfix

STRING(5)

Postfix at the end of the output. Default: ) (closing parenthesis).

FB_BA_DecorString 3: Outputs

Name

Type

Description

sOutput

T_MaxString

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)”

FB_BA_DecorString 4: Methods

Name

Definition location

Description

AddDecor_Family

Local

Adds formatted strings for decoration with 0–5 arguments (AddDecor–AddDecor5).

Reset

Local

Resets all outputs and the counter.

Finish

Local

Finalizes the decoration and combines the prefix and postfix.

FB_BA_DecorString 5: Properties

Name

Type

Access

Definition location

Description

IsEmpty

BOOL

Get

Local

Indicates whether no decorations have been added.