Find - Array

From Creation Kit
Jump to: navigation, search

Member of: All Arrays

Locates a particular value inside an array and returns the index

Syntax

int Function Find(;/element type/; akElement, int aiStartIndex = 0) native

Parameters

  • akElement: The element to locate
  • aiStartIndex: Where to start the search
    • Default: 0

Return Value

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

Examples

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


int firstPosition = MyStringArray.Find("Hello")
Debug.Trace("Found Hello at position " + firstPosition)
int secondPosition = MyStringArray.Find("Hello", firstPosition + 1)
Debug.Trace("Found a second Hello at position " + secondPosition)

See Also