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