SetSegment (FUN)

FUNCTION SetSegment : IString

Initializes the passed IString instance and uses the specified memory area for this purpose

Example for a 50 byte IString instance:

sValue : STRING(50) := UTF8#'CØD€šŸŠ ïß värÿ çôõl';
udiLength : UDINT := TO_UDINT(LEN(sValue));
   fbString : STR._UTF8String;
itfString : STR.IString := STR.SetSegment(fbString, ADR(sValue), SIZEOF(sValue)-1, udiLength);

Note

The final NULL byte of sValue is not part of the usable memory area of the string.
The values sValue[0]sValue[49] are part of the usable Memory area.
This is the reason for the expression SIZEOF(sValue)-1 when calling SetSegment
InOut:

Scope

Name

Type

Comment

Return

SetSegment

IString

Input

itfString

IString

String instance of an _UTF8String|

pbyMemory

POINTER TO BYTE

Pointer to the first byte of the memory.
This address should aligned to a __XWORD boundary!

udiSize

UDINT

Size of the whole allocated memory

udiLength

UDINT

Length of the segment in bytes

Output

eErrorID

ERROR