MapKey

Map command

Syntax

Gives the key of the current entry of a map.

MapKey(<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

The key, as text. "" when there is no current entry, and after FreeMap().

Good to know

  • The key is always text, even when the entry was written with a number: after m(2.5) = 1, MapKey() returns "2.5".
  • After a FOREACH or a NextMapElement() loop has reached the end, there is no current entry and MapKey() returns "".

Example

NewMap stock.i()stock("apple") = 3stock("pear") = 5FOREACH stock()  Console(MapKey(stock()) + " = " + Str(stock()))   ' apple = 3, pear = 5NEXTConsole("[" + MapKey(stock()) + "]")   ' []
In the manual : Arrays, lists and maps