Deserializing STRING - Manual - SIMATIC AX - System.Serialization - System.Serialization,

System.Serialization library

Portfolio
SIMATIC AX
Product
SIMATIC AX
Software version
10.3.25
Edition
01/2026
Language
English (original)
Package Name
@ax/system-serde

For STRING, the first byte at the given offset of the buffer is interpreted as the STRING length (number of CHARs), while each following byte in the buffer is interpreted as a CHAR in sequence. In the following example, the bytes starting from offset 1 of the buffer get deserialized and give the STRING value str = 'ab' with a length of 2.

USING System.Serialization;

FUNCTION SerDe_Demo
    VAR_TEMP
        data : ARRAY[0..4] OF BYTE := [BYTE#16#0, BYTE#16#2, BYTE#16#61, BYTE#16#62, BYTE#16#63];
        str : STRING;
        nextValueOffset : UDINT;
    END_VAR

    // str = 'ab'
    // nextValueOffset = 4
    nextValueOffset := Deserialize(UDINT#1, data, str);
END_FUNCTION