FB_BA_StringTokenizerLX

FB_BA_StringTokenizerLX 1:

Abstract function block for concatenating strings with an unlimited number of nesting levels. The function block analyzes strings containing nested placeholders and tokens and provides structured information for evaluation. This function block is designed to serve as the foundation for derived tokenizer implementations and enables specialized processing of the parsed tokens. Derived classes must implement the abstract method TermSign() to define the required delimiters.

Syntax

FUNCTION_BLOCK ABSTRACT FB_BA_StringTokenizerLX
VAR_OUTPUT
  nTokenCount    : BYTE;
  nMaxTokenLevel : BYTE;
END_VAR
END_FUNCTION_BLOCK

FB_BA_StringTokenizerLX 2: Outputs

Name

Type

Description

nTokenCount

BYTE

Number of tokens recognized in the analyzed string.

nMaxTokenLevel

BYTE

Maximum nesting depth of the detected tokens.

FB_BA_StringTokenizerLX 3: Methods

Name

Definition location

Description

Tokenize2

Local

Primary method for concatenation. Parses the input string and generates the token structure.

TokenizeAny

Local

Variant for the ANY_STRING parameter.

Reset

Local

Resets the tokenizer and deletes all parsed tokens.

TermSign

Local

Abstract method. Must be implemented by derived classes. Defines the opening, closing, and separator characters for the tokenization levels.

CompareTermName

Local

Compares the name of a term with a passed-in string.

CompareTermValue

Local

Compares the value of a term to a passed-in string.

GetChildTerm

Local

Retrieves a child term at a specific index.

GetChildToken

Local

Retrieves a child token at a specific index.

GetSubTermInfos

Local

Retrieves information about the terms contained in a token (number, name, and value).

GetTermDepth

Local

Determines the maximum nesting depth of a term.

GetTokenDepth

Local

Determines the maximum nesting depth of a token.

GetTermNameAny

Local

Retrieves the name of a term as an ANY type.

GetTermNamePtr

Local

Retrieves the name of a term as a pointer.

GetTermValueAny

Local

Retrieves the value of a term as an ANY type.

GetTermValuePtr

Local

Retrieves the value of a term as a pointer.

ReplaceTokenAny

Local

Replaces a token with a new value (ANY_STRING parameter).

ReplaceToken2

Local

Replaces a token with a new value.

FB_BA_StringTokenizerLX 4: Properties

Name

Type

Access

Definition location

Description

LogMsg

FB_BA_LogMessageItf

Get

Local

Reference to the logging framework (can be overridden in subclasses, if desired).

Examples of token formats

"Some text with a [Placeholder]."

Token: Placeholder

"Some text with a [Placeholder=123]."

Token: Placeholder with value: 123

"[AA=11{BB=22(xxx=666,yyy=777,zzz=888),CC=33(xx=66),DD=44(yy=77)},EE=55,FF=66]"

Nested tokens with values (3 levels)

FB_BA_StringTokenizerLX 5:
  • This function block is abstract and must be extended by derivation.
  • The derived class must implement the TermSign() method.
  • This function block is for beta testing and should be used with caution in production environments.
  • Test examples are located in the personal test project (TODO: Move to the BA2_Common repository).