XSIZEOF

XSIZEOF 1:

Available from TC3.1 Build 4026

The operator is an extension of the IEC 61131-3 standard.

The XSIZEOF operator determines the number of bytes needed in the passed variable or data type.

An unsigned value is always returned. The data type of the return value <return value> is specified as follows: on 64-bit platforms the type is ULINT, on all other platforms it is UDINT. To generate code that runs on all platforms, the return value can be declared with the __UXINT data type.

Syntax:

<return value> := XSIZEOF( <variable> );

Sample:

PROGRAM MAIN
VAR
    nReturnValue : __UXINT;             // Datentyp bei 64-bit-Plattformen: ULINT
    aData1       : ARRAY[0..4] OF INT;
END_VAR
nReturnValue := XSIZEOF(aData1);

Result:

nReturnValue = 10
XSIZEOF 2:

When assigning to a variable of type __UXINT it is advisable to use the operator XSIZEOF instead of the operator SIZEOF. This is because with XSIZEOF the data type of the return value depends on the platform. As a result, problems that occur when using the SIZEOF operator do not occur.