Difference between revisions of "Ar Next"

18 bytes added ,  10:59, 10 December 2014
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 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.
  |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-or-float-or-string
  |returnType = key:int/float/string
  |arguments =  
  |arguments =  
   {{FunctionArgument
   {{FunctionArgument
   |Name = Source
   |Name = Source
   |Type = array}}{{FunctionArgument
   |Type = array}}{{FunctionArgument
   |Name = Previous
   |Name = Key
   |Type = key}}}}
   |Type = int/float/string}}}}
==Example==
==Example==
<pre>
<pre>
array_var MyMap
array_var MyMap
int iKey ; * or float/string_var as appropriate for array
float MapKey ; * or string_var as appropriate for array
 
let MapKey := Ar_First MyMap ; * The First Key


let iKey := Ar_First MyMap ; * get first element
let MapKey := Ar_Next MyMap, MapKey ; * The Next Key


while iKey != Ar_BadNumericIndex
if MapKey == Ar_BadNumericIndex
     ; do something for every valid key in array
     ; Then there is no next key in the map
    let iKey := Ar_Next MyMap, iKey
endif
loop
</pre>
</pre>


Anonymous user