SearchElement (open)
Returns the index of an element in an ARRAY
Syntax
// Core function, no LOADLIB necessary
INTEGER FUNCTION SearchElement(VARIANT list, VARIANT element, INTEGER start)
Parameters
VARIANT list
ARRAY to look in
VARIANT element
Value to look for
INTEGER start
The position in the ARRAY to start searching, default is zero
Return value
INTEGER
Index of the value in the ARRAY. When not found, -1 is returned. Note that the first element in an ARRAY has index 0
Description
This function returns index of a specific value in an array. When the value is not found, -1 is returned. Value must be of a comparable type.
Examples
// returns 1
INTEGER example1 := SearchElement([0, 5, 10, 5, 0], 5);
// returns -1
INTEGER example2 := SearchElement(["yes", "no"], "maybe");
// returns 3
INTEGER example3 := SearchElement([0, 5, 10, 5, 0], 5, 2);