Appearance
StringToToken
Declaration
Function StringToToken( s : string; aSeparators : TFloSeparators) : TStringList
Example
pascal
procedure OnMapEvent(var Value:Variant);
var myList : TStringList;
begin
myList := StringToToken('abc|123|456', ['|']);
Value := myList[0]; //returns 'abc'
Value := myList[1]; //returns '123'
end;Description
Splits a string based on the given aSeparators characters and returns the items as a TStringList. You can then access individual items using the properties of the TStringList.
aSeparators is a list of separator characters. It must be in list notation, with square brackets at beginning and end. It can contain more than one separator character, for example: [',', '.', ';', ':']. Only single characters can be used as elements in the list.
Empty token items are NOT output to the TStringList. For example: StringToToken('123||ABC', ['|']) returns only two strings in the list (i.e. '123' and 'ABC'). This means that StringToToken might not be suitable for decoding and re-encoding lists that can have empty items (such as a line from a text file that has separated field values - e.g. a CSV file - because any empty fields will be dropped from the field list).