Difference between revisions of "FindStruct - Array"
Jump to navigation
Jump to search
imported>Qazaaq (added category) |
imported>DavidJCobb m (Made mention that asVarName parameter cannot be a variable, must be a raw string literal. Added example for clarity.) |
||
Line 9: | Line 9: | ||
== Parameters == | == Parameters == | ||
*asVarName: The name of the struct variable to compare with | *asVarName: The name of the struct variable to compare with (cannot be a variable, must be a raw string) | ||
*akElement: The element to locate | *akElement: The element to locate | ||
*aiStartIndex: Where to start the search | *aiStartIndex: Where to start the search | ||
Line 29: | Line 29: | ||
int secondPosition = MyPointArray.FindStruct("Y", 10, firstPosition + 1) | int secondPosition = MyPointArray.FindStruct("Y", 10, firstPosition + 1) | ||
Debug.Trace("Found a second point with an Y of 10 at position " + secondPosition) | Debug.Trace("Found a second point with an Y of 10 at position " + secondPosition) | ||
</source> | |||
<br/> | |||
<source lang="papyrus"> | |||
;bad, cannot pass a variable to asVarName, won't compile! | |||
String axis = "Y" | |||
int firstPosition = MyPointArray.FindStruct(axis, 10) | |||
</source> | </source> | ||
Latest revision as of 05:37, 5 February 2020
Member of: All Arrays
Locates a particular value in a struct inside an array and returns the index
Syntax[edit | edit source]
int Function FindStruct(StructVarName asVarName, ;/var type/; akElement, int aiStartIndex = 0) native
Parameters[edit | edit source]
- asVarName: The name of the struct variable to compare with (cannot be a variable, must be a raw string)
- akElement: The element to locate
- aiStartIndex: Where to start the search
- Default: 0
Return Value[edit | edit source]
The index of the struct in the array with the matching value, or a negative value if it was not found.
Examples[edit | edit source]
if (MyPointArray.FindStruct("X", 1) < 0)
Debug.Trace("Did not find a point with an X of 1 in the array")
endIf
int firstPosition = MyPointArray.FindStruct("Y", 10)
Debug.Trace("Found a point with an Y of 10 at position " + firstPosition)
int secondPosition = MyPointArray.FindStruct("Y", 10, firstPosition + 1)
Debug.Trace("Found a second point with an Y of 10 at position " + secondPosition)
;bad, cannot pass a variable to asVarName, won't compile!
String axis = "Y"
int firstPosition = MyPointArray.FindStruct(axis, 10)