Substring.Join Method

Overload List

#SignatureDescription
1class function Join(const Separator: string; const List: TSubstringList): Substr.Substring; overload; static;The items of List with Separator between them: Join over a TSubstringList.
2class function Join(const Separator: string; const List: TSubstringList; const StartIndex, Count: Integer): Substr.Substring; overload; static;
3class function Join(const Separator: string; const Values: array of const): Substr.Substring; overload; static;The values of an array of const with Separator between them.
4class function Join(const Separator: string; const Values: array of string): Substr.Substring; overload; static;The values with Separator between them.
5class function Join(const Separator: string; const Values: array of string; const StartIndex, Count: Integer): Substr.Substring; overload; static;

Overload 1: class function Join(const Separator: string; const List: TSubstringList): Substr.Substring; overload; static;

The items of List with Separator between them: Join over a TSubstringList.

#NameDescription
1Separator

The separator, every text kind.

Returns: Substring - The joined text.

Remarks:

The window form joins Count items from StartIndex (0-based), which must lie inside the list, else ESubstringRangeError is raised.

Examples

Joining a list, and a window of it.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('one');
        List.Add('two');
        List.Add('three');
        Assert(Substring.Join(', ', List) = 'one, two, three');
        Assert(Substring.Join('-', List, 1, 2) = 'two-three');
    finally
        List.Free;
    end;
end;

Overload 2: class function Join(const Separator: string; const List: TSubstringList; const StartIndex, Count: Integer): Substr.Substring; overload; static;

#NameTypeDescription
1Separatorstring
2ListTSubstringList
3StartIndexInteger
4CountInteger

Returns: Substring

Overload 3: class function Join(const Separator: string; const Values: array of const): Substr.Substring; overload; static;

The values of an array of const with Separator between them.

#NameTypeDescription
1Separatorstring
2Valuesarray of const

Returns: Substring - The joined text.

Remarks:

Numbers, Booleans, characters, texts and class names are written; any other element raises EConvertError.

Examples

Numbers and texts.

uses Substr;

procedure Example;
begin
    Assert(Substring.Join('|', [1, 'a', 'b']) = '1|a|b');
end;

Overload 4: class function Join(const Separator: string; const Values: array of string): Substr.Substring; overload; static;

The values with Separator between them.

#NameDescription
1Separator

Every text kind.

2Values

The strings joined; the window form joins Count of them from StartIndex (0-based), which must lie inside Values, else ESubstringRangeError is raised.

Returns: Substring - The joined text, sized once.

Remarks:

An array written of single characters, ['a', 'b'], matches this form and the array of const form alike, and the compiler refuses the call as ambiguous; an array of strings of other lengths, or a typed array, selects this one.

Examples

Joining strings, and a window of them.

uses Substr;

procedure Example;
begin
    Assert(Substring.Join(', ', ['one', 'two', 'three']) = 'one, two, three');
    Assert(Substring.Join('-', ['one', 'two', 'three'], 1, 2) = 'two-three');
end;

Overload 5: class function Join(const Separator: string; const Values: array of string; const StartIndex, Count: Integer): Substr.Substring; overload; static;

#NameTypeDescription
1Separatorstring
2Valuesarray of string
3StartIndexInteger
4CountInteger

Returns: Substring