SIZEOF
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.
Return value of SIZEOF(x) | 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 |
Samples:
Result: nVar is 10.
ST:
aArr1 : ARRAY[0..4] OF INT;
nVar : INT;
nVar := SIZEOF(aArr1); (*nVar := USINT#10;*)
See also