2-463
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Conversion Instructions
2
SizeOfAry
SizeOfAry
The SizeOfAry instruction gets the number of elements in an array.
* If you omit the input parameter, the default value is not applied. A building error will occur.
The SizeOfAry instruction gets the number of elements in array In[]. For the input parameter, use an
array name, such as array, and not an array element name, such as array[0].
The following figure shows a programming example.
Instruction Name FB/FUN Graphic expression ST expression
SizeOfAry Get Number of
Array Elements
FUN Out:=SizeOfAry(In);
Variables
Name Meaning I/O Description Valid range Unit Default
In[] (array) Array Input Array Depends on data type.
--- *
Out Number of
elements
Output Number of elements Depends on data type.
--- ---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
In[] (array)
OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
Arrays of enumerations or structures can also be specified.
Out OK
Function
(@)SizeOfAry
EN ENO
In Out
def:=SizeOfAry(abc);
LD ST
def
abc ARRAY[0..3] OF INT
abc
SizeOfAry
EN ENO
In
Variable
Data type
In[0]=abc[0]
In[1]=abc[1]
In[2]=abc[2]
In[3]=abc[3]
Out=def
UINT#4
Number of array elements