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

MapKeyFirst

Use this function to retrieve the first key in a map so that all the keys in a map can be discovered.

Syntax

STRING MapKeyFirst(STRING sMapName)

sMapName:

Name of map to get the value from.

Return Value

The first key in the map, if there are no keys in the map and empty string is returned.

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

Note: This key can then be used in MapKeyNext to discover all the property keys in the map.

Example

! Demonstrate MapKeyFirst.
STRING sMapName = MapOpen();
! sMapName is a randomly generated text that uniquely identifies the map
INT iMapSetValueResult1 = MapSetValue(sMapName, “somekey”, “somevalue”);
INT iMapSetValueResult2 = MapSetValue(sMapName, “SomeKey”, “SomeValue”);
STRING sMapKeyFirstResult = MapKeyFirst(sMapName);
! sMapKeyFirstResult will be set to “SomeKey”
! This shows that the keys are visited in alphabetical order, and that
! the keys are case sensitive
INT iMapCloseResult = MapClose(sMapName);
! The map that is identified by sMapName is now closed and unavailable		

Related Functions

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

See Also

Published June 2018