Hello, guys. I was trying to split a text in a memo, for example, "distance = 10" or "distance=10". The string should be split by "=" or " =" and get the value behind it, but my code doesn't assign the value to the related variables. How to solve this problem.
My codes are below:
var
Form1: TForm1;
i:integer;
A: TStringArray;
toxt: string;
dist,time:string;
procedure TForm1.Button1Click(Sender: TObject);
begin
for i:=0 to memo1.lines.count-1 do
begin
text:=memo1.lines[i];
If (Pos(' = ',toxt)>0) then
begin
A := toxt.Split(' = ');
if (A[0]='distance') then
begin
dist:=A[3];
end
else if A[0]='time' then
begin
time:=A[3];
end
else
if (Pos(' = ',toxt)=0) then
begin
A := toxt.Split('=');
if A[0]='distance' then
begin
dist:=A[3];
end
else if A[0]='time' then
begin
time:=A[3];
end
end;
end;
end;
showmessage(dist);
showmessage(time);
end;
end.