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

MapValueSet

Use this function to set a value of a map key.

Syntax

INT MapValueSet(STRING sMapName, STRING sKeyName, VARIANT Value INT nSetMode)

sMapName:

Name of the map to create or open.

sKeyName:

Name of the key to set.

Value:

Name of the value to be set

nSetMode:

0 - Create a new property

1- Override an existing property

2 - Assign the value whether the key already exists or not. This is the default mode.

Return Value

If the value is set correctly, the result is “No Error” (0), otherwise an error code is returned.

If the map name or key name is empty, an “Invalid argument” error (274) will be raised and returned.

If the map does not exist a “Record not found” error (536) will be returned.

If the key does not exist and set mode is 1, a “Record not found” error (536) will be returned.

If the key exists and set mode is 0, an “Out of handles” error (271) will be returned.

Example

! Demonstrate MapValueSet.
STRING sMapName = MapOpen();
! sMapName is a randomly generated text that uniquely identifies the map
INT iMapValueSetResult = MapValueSet(sMapName, “SomeKey”, “SomeValue”);
STRING sMapValueGetResult = MapValueGet(sMapName, “SomeKey”);
! sMapValueGetResult will be set to “SomeValue”
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, MapKeyFirst, MapValueGet, MapKeyNext, MapValueSetQuality

See Also

Published June 2018