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
SetSegmentInput
itfStringString instance of an_UTF8String|pbyMemoryPOINTER TO BYTE
Pointer to the first byte of the memory.This address should aligned to a__XWORDboundary!udiSizeUDINTSize of the whole allocated memoryudiLengthUDINTLength of the segment in bytesOutput
eErrorID