new_valueset
The new_valueset function is a non-class version of the CValueSet:new method which creates and returns a new CValueSet object.
S = new_valueset()
Default constructor. The value type is set "number" by default.
S = new_valueset("string")
Constructs a CValueset object and sets the value type to "string".
S = new_valueset( CValueSetOld )
Constructs a new CValueSet S and initializes it to the members of the existing CValueSetOld argument.
S = new_valueset( tbl )
Constructs a new CValueSet S from a 1-dimensional array with values that are numbers. 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 with no passed parameters. 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:
|
-- constructor, 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 1-dimensional array with values that are numbers. of pairs. Each pair contains a key and a value. In this example, the values are strings. The new_valueset function determines that the values are strings by determining the type of value in the first member of the 1-dimensional array with values that are numbers.:
|
-- create a 1-dimensional array with values that are numbers. |
|
--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 1-dimensional array with values that are numbers. |
|
-- result: Count = 4 |
|
-- result: "string" |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.