Basic instructions
8.6 Move operations
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
287
CountOfElements (Get number of ARRAY elements)
You can use the "Get number of ARRAY elements" instruction to query how many Array
elements are in a tag pointed to by a Variant.
If it is a one-dimensional ARRAY, the instruction returns the difference between the high and
low limit +1 is output. If it is a multi-dimensional ARRAY, the instruction returns the product of
all dimensions.
Table 8- 97 CountOfElements instruction
Result := CountOfElements(
_variant_in_);
Counts the number of array elements at
the array pointed to by the IN parameter.
Note
If the Variant points to an Array of Bool, the instruction counts the fill elements to the nearest
byte boundary. For example, the instruction returns 8 as the count for an Array[0..1] of Bool.
Table 8- 98 Parameters for the CountOfElements instruction
IN Variant Tag with array elements to be
Table 8- 99 ENO status
1 No error Instruction returns the number of array ele-
0 Enable input EN has the signal state "0" or the Variant
does not point to an array.
Instruction returns 0.