Difference between revisions of "Ar Next"
Improved example
imported>Odessa (Created page with "{{Function |origin = NVSE |summary = Returns the next key of an array, after that specified. For regular arrays (list arrays) this is just equivalent to <b>(SpecifiedKey + 1...") |
imported>Odessa (Improved example) |
||
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 the one 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 elements were inserted. | |||
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/float/string | ||
|arguments = | |arguments = | ||
{{FunctionArgument | {{FunctionArgument | ||
|Name = Source | |Name = Source | ||
|Type = array}}{{FunctionArgument | |Type = array}}{{FunctionArgument | ||
|Name = | |Name = Key | ||
|Type = | |Type = int/float/string}}}} | ||
==Example== | ==Example== | ||
<pre> | <pre> | ||
array_var MyMap | array_var MyMap | ||
float MapKey ; * or string_var as appropriate for array | |||
let MapKey := Ar_First MyMap ; * The First Key | |||
let | let MapKey := Ar_Next MyMap, MapKey ; * The Next Key | ||
if MapKey == Ar_BadNumericIndex | |||
; | ; Then there is no next key in the map | ||
endif | |||
</pre> | </pre> | ||