Editing Ar Next
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
{{Function | {{Function | ||
|origin = NVSE | |origin = NVSE | ||
|summary = Returns the next key of an array, after | |summary = Returns the next key of an array, after that specified. For regular arrays (list arrays) this is just equivalent to <b>(SpecifiedKey + 1)</b>. This function is most useful for map and stringmap arrays, where keys are dynamic. Note that map and stringmap arrays are always sorted in ascending numeric or alphanumeric order, regardless of the order of element insertion. | ||
Note that map and stringmap arrays are always sorted in ascending numeric or alphanumeric order, regardless of the order | |||
Returns a bad index ([[Ar_BadNumericIndex]] or [[Ar_BadStringIndex]]) if there is no next key in the array. | Returns a bad index ([[Ar_BadNumericIndex]] or [[Ar_BadStringIndex]]) if there is no next key in the array. | ||
|name = Ar_Next | |name = Ar_Next | ||
|returnType = key:int | |returnType = key:int-or-float-or-string | ||
|arguments = | |arguments = | ||
{{FunctionArgument | {{FunctionArgument | ||
|Name = Source | |Name = Source | ||
|Type = array}}{{FunctionArgument | |Type = array}}{{FunctionArgument | ||
|Name = | |Name = Previous | ||
|Type = | |Type = key}}}} | ||
==Example== | ==Example== | ||
<pre> | <pre> | ||
array_var MyMap | array_var MyMap | ||
int iKey ; * or float/string_var as appropriate for array | |||
let | let iKey := Ar_First MyMap ; * get first element | ||
while iKey != Ar_BadNumericIndex | |||
; | ; do something for every valid key in array | ||
let iKey := Ar_Next MyMap, iKey | |||
loop | |||
</pre> | </pre> | ||