CValueSet:Add


The Add method adds a member at the end of the CValueSet object. Each member consists of a (key, value) pair. The value must be of type "number", "integer", "string", or "boolean" that matches the type of the CValueSet object. Otherwise, the value will be converted to the type of the object. The object type can be changed using the SetType method.

Syntax

boolean = CValueSet:Add( key, number_value )

boolean = CValueSet:Add( key, integer_value )

boolean = CValueSet:Add( key, string_value )

boolean = CValueSet:Add( key, boolean_value )

bullet.gif    Adds the (key, value) pair at the end of the CValueSet object and returns the index of the object or 0 on failure. The difference between a number and an integer is determined by the type of the CValueSet.

Example

The following example creates a CValueSet S and adds members to it:

S = new_valueset()

-- constructor, default to values of type "number"

S:Add( "first key", 15.5 )

-- add a key and value

S:Add( "second key", -7.23 )

-- add a key and value

S:Add( "third key", 0.923 )

-- add a key and value

 

 

The following example uses the CValueSet reated above. It resets the type and then adds string values to the same object:

S:SetType("string")

-- change the type to "string". S is automatically emptied.

S:Add( "first key", 15.5 )

-- add a key and value

S:Add( "second key", -7.23 )

-- add a key and value

S:Add( "third key", 0.923 )

-- add a key and value

Related Topics

CValueSet Class, SetAt, RemoveAt, InsertAt, SetAt


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.