CValueSet:InsertAt


The InsertAt method adds a member to the CValueSet at the specified set index. THis is inserted before the current member at the specified index. Conversely, the Add method inserts at the current end of the set.

Syntax

boolean = CValueSet:InsertAt( nIndex, number_value )

boolean = CValueSet:InsertAt( nIndex, integer_value )

boolean = CValueSet:InsertAt( nIndex, string_value )

boolean = CValueSet:InsertAt( nIndex, boolean_value )

bullet.gif    Inserts the (key, value) pair at the specified set index, nIndex, before the pair at the current nIndex.

Example

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

S = new_valueset("number")

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

S:Add( "key_1", 15.5 )

-- add a key and value at index 1

S:Add( "key_2", -7.23 )

-- add a key and value at index 2

S:Add( "key_3", 78.6 )

-- add a key and value at index 3

Printf("Old N= %d", S:Count())

-- Result: Old N= 3

S:InsertAt( 2, "new key", 0.9 )

-- inserts the new key and value between "key_1" and "key_2"

Printf("New N= %d", S:Count())

-- Result: New N= 4

 

Related Topics

CValueSet Class, Add, Set, RemoveAt, InsertAt, SetAt


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