Skip to main content

Operator: SIZEOF

Tip

In compiler version 3.5.16.0 and higher, the XSIZEOF operator should be used instead of this operator.

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

Syntax:

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

The operator determines the number of bytes which are needed in the passed variable or data type. An unsigned value is always returned. The type of the return value is adapted to that of the passed operand (variable or data type).

Return value: <return value>

Data type of the return value which is used implicitly

0 <= <return value> <256

USINT

256 <= <return value> < 65536

UINT

65536 <= <return value> < 4294967296

UDINT

4294967296 <= <return value>

ULINT

Example 111. Example in ST
PROGRAM PLC_PRG
VAR
	aData_1 : ARRAY[0..4] OF INT;
	iReturnValue : INT;
END_VAR
iReturnValue := SIZEOF(aData_1);  (* iReturnValue := USINT#10; *)

The result in iReturnValue is 10.