SIZEOF

Overview

This arithmetic operator is not specified by the standard IEC 61131-3.

You can use it to determine the number of bytes required by the given variable x.

The SIZEOF operator returns an unsigned value. The type of the return value will be adapted to the found size of variable x.

Return Value of SIZEOF(x)

Data Type of the Constant Implicitly Used for the Found Size

0 ≤ size of x < 256

USINT

256 ≤ size of x < 65,536

UINT

65,536 ≤ size of x < 4,294,967,296

UDINT

4,294,967,296 ≤ size of x

ULINT

Example in ST

var1 := SIZEOF(arr1);  (* d.h.: var1:=USINT#10; *)

Example in IL

Result is 10

arr1:ARRAY[0..4] OF INT;
Var1:INT;

LD     arr1
SIZEOF
ST     Var1