SIZEOF

SIZEOF 1:

As of TwinCAT 3.1 Build 4026, use the XSIZEOF operator instead of this operator.

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

The operator is used to determine the number of bytes required by the specified variable x. The SIZEOF operator always returns an unsigned value. The type of the return variable adapts to the detected size of variable x.

Syntax:

<return value> := SIZEOF( <variable name> | <date type name> );

Return value of SIZEOF(x) (<return value>)

Data type of the constant, which TwinCAT implicitly uses for the size that was found.

0 <= size of x < 256

USINT

256 <= size of x < 65536

UINT

65536 <= size of x < 4294967296

UDINT

4294967296 <= size of x

ULINT

Sample:

PROGRAM MAIN
VAR
    aArr1 : ARRAY[0..4] OF INT; 
    nSize : INT;
END_VAR
nSize := SIZEOF(aArr1);

Result:

nSize = 10.