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

MapKeyExists

Use this function to check if a key exists in a map.

Syntax

INT MapKeyExists(STRING sMapName, STRING sKeyName)

sMapName:

Name of map to get the value from.

sKeyName:

Name of the key to get the value from.

Example

! Demonstrate MapKeyExists.
STRING sMapName = MapOpen();
! sMapName is a randomly generated text that uniquely identifies the map
INT iMapKeyExistsResultExpectFalse = MapKeyExists(sMapName, “SomeKey”);
! iMapKeyExistsResultExpectFalse will be set to FALSE (zero)
INT iMapValueSetResult = MapValueSet(sMapName, “SomeKey”, “SomeValue”);
INT iMapKeyExistsResultExpectTrue = MapKeyExists(sMapName, “SomeKey”);
! iMapKeyExistsResultExpectTrue will be set to TRUE (non-zero)
INT iMapCloseResult = MapClose(sMapName);
! The map that is identified by sMapName is now closed and unavailable		

Return Value

TRUE if the map exists, or FALSE if not.

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

Related Functions

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

See Also

Published June 2018