I made my own parsing routine:
[pascal]procedure ExplodeText(
const Text: string;
var Dest: array of string;
const Separator: string = '';
TrimSpaces: Boolean = True
);
var
IText: Integer;
Part: string;
begin
IText := 1;
if Separator = '' then
begin
// Interpret spaces as separators.
while IText <= Length(Text) do
begin
Part := '';
while (IText <= Length(Text)) and (Text[IText] <= #32) do
begin
Inc(IText);
end;
while (IText <Length> #32) do
begin
Part := Part+Text[IText];
Inc(IText);
end;
SetLength(Dest, Length(Dest)+1);
Dest[High(Dest)] := Part;
end;
end else
begin
while IText <= Length(Text) do
begin
Part := '';
while (IText <= Length(Text)) and (Copy(Text, IText,
Length(Separator)) <> Separator) do
begin
Part := Part+Text[IText];
Inc(IText);
end;
SetLength(Dest, Length(Dest)+1);
if TrimSpaces then
Dest[High(Dest)] := Trim(Part) else
Dest[High(Dest)] := Part;
Inc(IText, Length(Separator));
end;
end;
end;[/pascal]
You can use any space (<= #32) as separator, or a given string and remove spaces surrounding the results.
Any syntax error might be due to the translation I just made to post it here.
Bookmarks