NextMapElement

Map command

Syntax

Moves to the next entry of a map and makes it current. Entries come in the order they were created.

NextMapElement(<map>())

Parts

<map>The map, written with its empty parentheses: stock(). It must be a NewMap variable or a map field of a record.

Returns

1 when it moved to an entry, 0 past the last one.

Good to know

  • Call ResetMap() first to start from the first entry. Without it, the walk starts after the current entry, which is often the last one written.
  • Past the end, there is no current entry and every further call returns 0 until ResetMap().
  • Write the test as WHILE NextMapElement(m()) or = 1: the result is a number.

Example

NewMap stock.i()stock("apple") = 3stock("pear") = 5total = 0ResetMap(stock())WHILE NextMapElement(stock())  total = total + stock()WENDConsole(Str(total))   ' 8
In the manual : Arrays, lists and maps