CSet:GetMember CSet:RemoveAt

CSet:Insert


The Insert method adds a member to the Set prior to a specified index.

Syntax

CSet:Insert( member, index )

    member is the object to insert.

    index is a number that specifies the insertion point, beginning at 1.

Remarks

The member is inserted before the member already existing at index. To insert prior to the beginning of the set, use index = 1. Insertion moves all the members down in the list to open up the new position at index. In comparison with insertion, the Append method adds a member at the end of the set and does not need to know the index.

Example

Suppose a CSet exists with name S and that it contains 10 strings. The following script fragment inserts a new string "ABC" at index 5:

 

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

-- result: Count = 10

S:Insert("ABC", 5)

-- Insert the new string at position 5

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

-- result: Count = 11

Related Topics

CSet, Append