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 listARRAY to look in
VARIANT elementValue to look for
INTEGER startThe position from which the backward search starts, default is 2147483647
Return value
INTEGERIndex 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);