Skip to content

Variables (Map)

Variables may also be map type.

Name
Type

A map is a series of couples of key/value data.
In this example we have 50 couples with:
- Key = 0 - 49
- Value = "Index " + Key

    MapName = "MyMap"
    -- Add 50  couples to "MyMap"
    for i=0,50,1
    do
        worked = resiot_map_add(MapName, i, "Index " .. i)
    end

    -- Get the value at 33th
    Value = resiot_map_get(MapName, 33)
    resiot_globaldebug(Value)

    -- Edit the value at 46th
    worked = resiot_map_edit(MapName, 46, "It's 08:58")
    resiot_globaldebug(resiot_map_get(MapName, 46))

    -- Remove the value at 20th
    worked = resiot_map_remove(MapName, 20)

    -- Check value at index 20 exists
    exists = resiot_map_exists(MapName, 20)

    if exists then
        resiot_globaldebug("Exists")
    else
        resiot_globaldebug("Does not exists")
    end

Result:
Result

Other function:
- resiot_map_count = Count the number of couples in a map;
- resiot_map_reset = Empty a map;
- resiot_map_exists = Check if exists a value at given index.