CValueSet:new
The new method creates an instance of the CValueSet class and returns a reference to the object. Each member of CValueSet is a pair consisting of a string key and a value of type "number", "integer", "string", or "boolean". The new CValueSet may be initialized to a specific value type, an existing CValueSet, a lua table of pairs, or to the default value type of "number". Note that the object can also be created using new_valueset.
Note: This method's name uses all lower case to present it as the analog of the C++ new operator. Generally, the names of class methods begin with an uppercase letter but new and delete are different.
S = CValueSet:new()
Default constructor. The value type is set "number" by default.
S = CValueSet:new("string")
Constructs a CValueset object and sets the value type to "string".
S = CValueSet:new( CValueSetOld )
Constructs a new CValueSet S and initializes it to the members of the existing CValueSetOld argument.
S = CValueSet:new( tbl )
Constructs a new CValueSet S from a lua table of pairs. The first member of each pair is the string kley and the second member is the value of type "number", "integer", "string", or "boolean".
On failure, nil is returned.
The following example shows the use of a default constructor. This defaults the value type to "number":
|
-- create a new instance S of the CValueSet class. |
|
-- other uses of the class go here, between new and delete. |
|
-- deletes the object and its associated memory. |
The following example creates a CValueSet S, adds members to it, then creates a second CValueSet containing the same members as the first set:
|
-- creator, default to values of type "number" |
|
-- add a key and value |
|
-- add a key and value |
|
-- add a key and value |
|
-- result: Count = 3 |
|
-- create S2 and initialize it to members of S |
|
-- result: Count = 3 |
|
-- result: "number" |
The following example creates a new CValueSet from a lua table of pairs. Each pair contains a key and a value. In this example, the values are strings. The new CValueSet:new() method determines that the values are strings by determining the type of value in the first member of the lua table:
|
-- create a lua table |
|
--Assign a key and value to table[1] |
|
-- Assign a key and value to table[2] |
|
-- Assign a key and value to table[3] |
|
-- Assign a key and value to table[4] |
|
-- create S from the lua table |
|
-- result: Count = 4 |
|
-- result: "string" |
CValueSet Class, Copy, delete, CSet, new_valueset
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.