// Screenshot of running sample application
procedure TForm1.btnParseClick(Sender: TObject);
begin
ParseDelimited(Memo1.lines, edit1.text, edit2.text);
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
edit3.Text:=Edit1.Text+Edit2.Text;
end;
procedure TForm1.ParseDelimited(const sl: TStrings; const value:string,
delimiter: string);
// Originally from : http://delphi.about.com/od/adptips2005/qt/parsedelimited.htm
// Tweak a bit by me, to be more understand to read
// to use it in your own program don't forget to remove all "memo2.lines" Lines.
var
nPosDeli : integer;
sGet : string;
sProcess : string;
nLenDeli : integer;
begin
nLenDeli := Length(delimiter) ;
sProcess := value + delimiter;
sl.BeginUpdate;
sl.Clear;
memo2.lines.clear;
try
while Length(sProcess) > 0 do
begin
memo2.Lines.Add('[sProcess] : '+sProcess);
memo2.Lines.Add('Length(sProcess) : '+IntToStr(Length(sProcess)));
nPosDeli := Pos(delimiter, sProcess) ;
memo2.Lines.Add('Pos(delimiter, sProcess) [nPosDeli] : '+IntToStr(nPosDeli));
sGet := Copy(sProcess,0,nPosDeli-1) ;
memo2.Lines.Add('Copy(sProcess,0,nPosDeli-1) [sGet] : '+sGet);
sl.Add(sGet) ;
sProcess := Copy(sProcess,nPosDeli+nLenDeli,MaxInt) ;
memo2.Lines.Add('Copy(sProcess,nPosDeli+nLenDeli,MaxInt) [sProcess]: '+sProcess);
memo2.Lines.Add(' ');
end;
finally
sl.EndUpdate;
end;
end;