Cicode Programming Reference > Cicode Function Categories > Map Functions > MapKeyCount

MapKeyCount

Use this function to retrieve the number of keys in a map.

Syntax

INT MapKeyCount(STRING sMapName)

sMapName:

Name of the map.

Return Value

The number of keys in the map, or a value less than 0 if an error is encountered.

If the map name is empty an “Invalid argument” error (274) will be raised.

Example

! Demonstrate MapKeyCount.
STRING sMapName = MapOpen();
! sMapName is a randomly generated text that uniquely identifies the map
INT iMapKeyCountResultExpectZero = MapKeyCount(sMapName);
! iMapKeyCountResultExpectZero will be set to 0
INT iMapValueSetResult = MapValueSet(sMapName, “SomeKey”, “SomeValue”);
INT iMapKeyCountResultExpectOne = MapKeyCount(sMapName);
! iMapKeyCountResultExpectOne will be set to 1
INT iMapCloseResult = MapClose(sMapName);
! The map that is identified by sMapName is now closed and unavailable			

Related Functions

MapClear, MapOpen, MapClose, MapExists, MapKeyDelete, MapKeyExists, MapKeyFirst, MapValueGet, MapKeyNext, MapValueSet, MapValueSetQuality

See Also

Published June 2018