F_FormatArgToStr

F_FormatArgToStr 1:

Format helper function. This function is used internally by the FB_FormatString function block. The function can be used to convert a variable of type T_Arg into a formatted string according to the format specification.

F_FormatArgToStr 2: Return value

Name

Type

Description

F_FormatArgToStr

UDINT

 

F_FormatArgToStr 3: Inputs

Name

Type

Description

bSign

BOOL

The sign flag.

bBlank

BOOL

The blank flag.

bNull

BOOL

The null flag.

bHash

BOOL

The hash prefix flag.

bLAlign

BOOL

The alignment flag (TRUE=left align).

bWidth

BOOL

If TRUE, the iWidth parameter is evaluated, otherwise not.

iWidth

INT

Width parameter.

iPrecision

INT

: Precision parameter.

eFmtType

E_TypeFieldParam

Type parameter (type: E_TypeFieldParam).

arg

T_Arg

The argument to be formatted. The following helper functions can be used to convert PLC variables of different types into the required data type T_Arg: F_BYTE, F_WORD, F_DWORD, F_LWORD, F_SINT, F_INT, F_DINT, F_LINT, F_USINT, F_UINT, F_UDINT, F_ULINT, F_STRING, F_REAL, F_LREAL.

F_FormatArgToStr 4:/F_FormatArgToStr 5: Inputs/outputs

Name

Type

Description

sOut

T_MaxString

If successful, this variable returns the formatted output string (type: T_MaxString).

Return parameter

Meaning

0

No error

<> 0

Error. Error description can be found at: Format error codes

Examples:

Formatting a BYTE variable as a binary string.

The result:

s1 = '10000000'
s2 = '            10000000'
s3 = '10000000            '
s4 = '2#10000000          '
L1 = 8
L2 = 20
L3 = 20
L4 = 20

Formatting an LREAL variable.

The result:

s1 = '12345.67890000'
s2 = '      12345.67890000'
s3 = '12345.67890000      '
s4 = '00000012345.67890000'
s5 = '+12345.67890000     '
L1 = 14
L2 = 20
L3 = 20
L4 = 20
L5 = 20

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, Arm®)

Tc2_Utilities (System)