RFind - Array

From the Fallout4 CreationKit Wiki
Revision as of 18:40, 11 July 2014 by imported>Plplecuyer
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Member of: All arrays

Locates a particular value inside an array and returns the index, starting from the end of the array, and moving to the beginning.

Syntax

int Function RFind(;/element type/; akElement, int aiStartIndex = -1) native

Parameters

  • akElement: The element to locate
  • aiStartIndex: Where to start the search. If this is -1 it starts at the end of the array.
    • Default: -1

Return Value

The index of the item in the array, or a negative value if it was not found.

Examples

if (MyIntArray.RFind(1) < 0)
  Debug.Trace("Did not find 1 in the array")
endIf


int firstPosition = MyStringArray.RFind("Hello")
Debug.Trace("The last Hello is at position " + firstPosition)
int secondPosition = MyStringArray.RFind("Hello", firstPosition - 1)
Debug.Trace("Found second to last Hello at position " + secondPosition)

See Also