Mitsubishi QD51 Programming Manual page 542

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
SEARCH
Function
• Searches for the specified value among the elements of the selected array variable and
returns the position of the element.
SEARCH (<array variable name>,<value to be searched for>[,<start element
Syntax
position>][,<step value>] )
array variable name
value to be searched for
start element position
step value
A=SEARCH(B%,5,0,3)
Examples
• The SEARCH function searches for the value specified in <value to be searched for> in the
Description
array variable specified in <array variable name> and returns the number of the array
element where the value is found for the first time.
The target of the search is from the element specified in <start element position> to the
last element of the applicable array variable.
If the specified value is not found in the array variable, -1 is returned.
• If the specified array variable is not a one-dimensional integer array variable, an "Illegal
function call" error occurs.
• The array variable specified in <array variable name> must be defined using the DIM
instruction before executing the SEARCH function.
• If <value to be searched for> is specified as a real number, it is first converted to an integer
and then the function is executed.
• If <start element position> is omitted, the search is started from the first element.
• If <step value> is omitted, it is assumed that "1" is specified and all the elements are
searched through.
11 - 372
SEARCH
• • • •
• • • •
• • • •
• • • •
• • • •
B%(0)
B%(1)
B%(2)
Searches from B%(0)
in increments of 3.
Specify the array variable to be searched through
(one-dimensional integer array variables only).
Specify the integer value to be searched for in the
array.
Specify from which element to start the search.
Specify the increment of the elements to be
searched through.
Finds the number 5 in the array B%, start searching
from B%(0) in increments of 3.
B%(3)
B%(4)
B%(5)
MELSEC-Q
"5"
B%(6)
• • • • • •
Returns the element
number 6 of the array
where "5" was found.
11 - 372

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents