HTBasic Help
×
Menu
Index

MAT SEARCH

Searches an array for user specified conditions.
 
 MAT SEARCH numeric-array [num-key], rule; return [,start]
MAT SEARCH string-array$ [str-key], rule; return [,start]
 
Usage:
MAT SEARCH Vector,#LOC(<>PI);Not_pi
MAT SEARCH Temperature,LOC MAX;Hottest
MAT SEARCH Students,LOC(<.33);Flunk,4
MAT SEARCH Titles$(*,2,3) DES,MAX;Last_book$
MAT SEARCH Array$(*), LOC(=Target$);I
 
Example: MAT SEARCH.BAS
 
Description:
A numeric or string array is searched for the specified condition and the result is returned in the return variable. The keyword DES specifies descending search order. The optional start value specifies the starting subscript. If not specified, searching begins with the first element for ascending searches and the last element for descending searches. The "rule" specifies the search rules to use and what to return:        
 
Rule
Meaning
LOC
Subscript of first element satisfying operator
#LOC
Count the number of elements satisfying operator
LOC MAX
Subscript of maximum value
LOC MIN
Subscript of minimum value
MAX
Find and return the maximum value
MIN
Find and return the minimum value
 
COMPLEX Arrays
MAT SEARCH can search an array, but since the concept of linear ordering does not apply to the complex plane, greater than, less than, MIN and MAX operations are not allowed.
 
See Also: