Resolve it in logical steps
1) Search for the first delimiter in the target
2) if found store the index
3) kick the delimiter out
4) search for another delimiter in the remainder of the target
5) if found retrieve the substring from the original target
6) insert messages to check the function of your program
ingredients:
1) a form (of course)
2) an editbox
3) a label
4) a button
procedure TForm1.Button1Click(Sender: TObject);
var master1, master2, delimiter, found : string;
i, j : integer; //operating variables
begin
delimiter :=';';
master1:= edit1.Text;
i:= pos(delimiter, master1); //Step 1-2
if i > 0 then
begin
master2 := master1;
delete(master2,i,1); // Step 3
j:= pos(delimiter, master2); //Step 4
if j > 0 then
begin
j := j +1;
found := copy(master1,(i+1),(j-i-1)); //Step 5
label1.Caption := found;
end
else MessageDlg('No 2nd delimiter found',mtError,[mbOK],0);
end
else MessageDlg('No 1st delimiter found',mtError,[mbOK],0);
end;
Regards S. van Els
SAvanEls@cq-link.sr