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
Input
itfString
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 memoryudiLength
UDINT
Length of the segment in bytesOutput
eErrorID