Operator ‘SIZEOF’ΒΆ

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

This operator is used for defining the number of bytes that are required by the variable x. The SIZEOF operator always yields an unsigned value. The type of return variable adapts to the detected size of the variable x.

Return Value of SIZEOF(x) Data type of the constant (CODESYS uses this implicitly for detected size)
0 <= size of x < 256 USINT
256 <= size of x < 65536 UINT
65536 <= size of x < 4294967296 UDINT
4294967296 <= size of x ULINT

Examples

Result in Var1: 10

ST:

arr1 : ARRAY[0..4] OF INT;
Var1 : INT;
var1 := SIZEOF(arr1);  (* var1 := USINT#10; *)