TheGameCreators / AGK-Studio

3 stars 1 forks source link

Help missing for .IndexOf() #879

Open VirtualNomad19 opened 2 years ago

VirtualNomad19 commented 2 years ago

new .IndexOf array search functionality undocumented outside of the Change log.

Syntax: index = MyArray.IndexOf ( Value )

Result: if Value found, will return first Index of MyArray containing Value, else returns -1

i expect .IndexOf will only search the first variable of Typed arrays similar to .find (sorted) behavior?

perhaps overhaul of Array Help in general necessary where we have 2 separate guides (v1 + v2 now named Arrays Enhanced)?

adambiser commented 2 years ago

Also, an error message for this command is off. I was wondering whether indexof() has a "start index" optional parameter (it does not, but it would be nice if it did).

Tried:

numbers as integer[10] = [0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0]
index as integer
index = numbers.indexof(0)
index = numbers.indexof(0, index + 1)

Error was "Error: Unexpected token ",", array find must be in the format .find(item)" should say "Error: Unexpected token ",", array find must be in the format .indexof(item)"

And again, an optional start index parameter would make this function even more useful.