2 Instruction Descriptions
2-488
NJ-series Instructions Reference Manual (W502)
The RecRangeSearch instruction searches Size elements in the array of structures In[]. The search
range is therefore from In[0] to In[Size
−
1]. The instruction searches member to search Member in the
structures for members that match the search condition.
Condition specifies the search condition. Mode specifies the search method. Details are provided
below. One of the members to search in the elements of In[] is passed as an argument to Member.
If any elements that match the search condition are found, the value of search result Out changes to
TRUE. The element number of the matching element is assigned to InOutPos[0] and the number of
matching elements is assigned to Num. If there is more than one matching element, the element num-
ber of the lowest matching element in In[] is assigned to InOutPos[0]. If there are no matching elements,
the value of Out will be FALSE and InOutPos[0] and Num will be 0.
Always attach the element number to input parameter that is passed to In[], e.g., array[3].
The data type of search condition Condition is enumerated type _eSEARCH_CONDITION. The mean-
ings of the enumerators are as follows:
The data type of search method Mode is enumerated type _eSEARCH_MODE. The meaning of the
enumerators are as follows:
For a linear search, the search is performed in order from the first element of In[].
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) Specify an array of structures.
Size OK
Member OK OK OK OK OK OK OK OK OK OK
Specify the same data type as the search member of In[].
MN Must be the same data type as Member.
MX Must be the same data type as Member.
Condition Refer to Function for the enumerators for the enumerated type _eSEARCH_CONDITION.
Mode Refer to Function for the enumerators for the enumerated type _eSEARCH_MODE.
InOutPos[]
(array)
OK
Out OK
Num OK
Function
Enumerator Meaning
_EQ_BOTH MN ≤ Member ≤ MX
_EQ_MIN MN ≤ Member < MX
_EQ_MAX MN < Member ≤ MX
_NE_BOTH MN < Member < MX
Enumerator Meaning
_LINEAR Linear search
_BIN_ASC Ascending binary search
_BIN_DESC Descending binary search