SplitString splits a string S based on the aChar character, and returns the item given by aIndex.

aIndex is a 1-based array - an index value of 1 returns the first split item.

If the string does not contain aChar, the aIndex value has to be one (1) so that the whole string is returned as the first split item.

If the string does not contain aChar, and the aIndex value is not one (1), then the returned string will be empty.

Declaration: Function SplitString( const S : string; aIndex : integer; aChar : Char) : string

Examples follow.

procedure OnMapEvent(var Value:Variant);
begin
Str1 := SplitString('abc|123|456', 2, '|'); //Returns 123
Str2 := SplitString('abc|123|456', 3, '|'); //Returns 456
Str3 := SplitString('abc|1234567890|456', 2, '|'); //Returns 1234567890
Str4 := SplitString('abc?1234567890,456', 2, '|'); //Returns an empty string
Str5 := SplitString('abc?1234567890,456', 1, '|'); //Returns abc?1234567890,456
end;