TSubstringList.Insert Method

procedure Insert(const Index: Integer; const S: string); overload;

Inserts S at Index (0..Count); the later items move up by one.

#NameDescription
1Index

The new item's index, 0..Count.

2S

The text, every text kind.

Result: stored in self (calling object)

Remarks:

Only the items' order changes: no text moves. A sorted list, or an Index outside 0..Count, raises EStringListError.

Examples

Inserting at the front.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('b');
        List.Insert(0, 'a');
        Assert(List[0] = 'a');
        Assert(List[1] = 'b');
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.InsertObject, TSubstringList.Add, TSubstringList.Add, TSubstringList.Move