Код: Выделить всё
procedure analysis1_mul(obj:TStringGrid; smul:integer; ymul:string; k:integer; kol:integer);
var pst,i,c,d,k1,k2:integer;
begin
while smul>0 do begin
k1:=0; k2:=0;
pst:=pos('*',ymul); c:=pst-1; d:=pst+1;
for i:=d to k do begin
if (copy(ymul,i,1)='*') or (copy(ymul,i,1)='+') or (copy(ymul,i,1)='~') or (copy(ymul,i,1)='>') then begin k2:=i-1; break end
else k2:=k; end;
if pst=1 then begin
k1:=1;
obj.cells[kol,0]:=obj.cells[kol-1,0]+copy(ymul,k1,k2-k1+1);
delete(ymul,k1,k2-k1+1);
if (pos('+',ymul)=1) or (pos('~',ymul)=1) or (copy(ymul,i,1)='>') then delete(ymul,1,1);
inc(kol); dec(smul); continue
end else
for i:=c downto 1 do
if (copy(ymul,i,1)='*') or (copy(ymul,i,1)='+') or (copy(ymul,i,1)='~') or (copy(ymul,i,1)='>') then begin k1:=i+1; break; end
else k1:=1;
obj.cells[kol,0]:=copy(ymul,k1,k2-k1+1);
delete(ymul,k1,k2-k1+1);
if (pos('+',ymul)=1) or (pos('~',ymul)=1) or (copy(ymul,i,1)='>') then delete(ymul,1,1);
inc(kol); dec(smul);
end;
end;
procedure analysis1_slozh(obj:TStringGrid; sslozh:integer; yplus:string; k:integer; kol:integer);
var k1,k2,c,d,pst,i:integer;
begin
while sslozh>0 do begin
k1:=0; k2:=0;
pst:=pos('+',yplus); c:=pst-1; d:=pst+1;
for i:=d to k do
if (copy(yplus,i,1)='+') or (copy(yplus,i,1)='~') or (copy(yplus,i,1)='>') then begin k2:=i-1; break end
else k2:=k;
if pst=1 then begin
k1:=1;
obj.cells[kol,0]:=obj.cells[kol-1,0]+copy(yplus,k1,k2-k1+1);
delete(yplus,k1,k2-k1+1);
if (pos('~',yplus)=1) or (pos('>',yplus)=1) then delete(yplus,1,1);
inc(kol); dec(sslozh); continue
end else
for i:=c downto 1 do
if (copy(yplus,i,1)='+') or (copy(yplus,i,1)='~') or (copy(yplus,i,1)='>') then begin k1:=i+1; break; end
else k1:=1;
obj.cells[kol,0]:=copy(yplus,k1,k2-k1+1);
delete(yplus,k1,k2-k1+1);
if (pos('~',yplus)=1) or (pos('>',yplus)=1) then delete(yplus,1,1);
inc(kol); dec(sslozh);
end;
end;
procedure analysis1_imp(obj:TStringGrid; simp:integer; yimp:string; k:integer; kol:integer);
var k1,pst,k2,c,d,i:integer;
begin
while simp>0 do begin
k1:=0; k2:=0;
pst:=pos('>',yimp); c:=pst-1; d:=pst+1;
for i:=d to k do
if (copy(yimp,i,1)='~') or (copy(yimp,i,1)='>') then begin k2:=i-1; break end
else k2:=k;
form1.label3.caption:=inttostr(c)+' '+inttostr(d);
if pst=1 then begin
k1:=1;
obj.cells[kol,0]:=obj.cells[kol-1,0]+copy(yimp,k1,k2-k1+1);
delete(yimp,k1,k2-k1+1);
if (pos('~',yimp)=1) then delete(yimp,1,1);
inc(kol); dec(simp); continue
end else
for i:=c downto 1 do
if (copy(yimp,i,1)='~') or (copy(yimp,i,1)='>') then begin k1:=i+1; break; end
else k1:=1;
obj.cells[kol,0]:=copy(yimp,k1,k2-k1+1);
delete(yimp,k1,k2-k1+1);
if (pos('~',yimp)=1) then delete(yimp,1,1);
inc(kol); dec(simp);
end;
end;
procedure analysis1_ekv(obj:TStringGrid; sekv:integer; yekv:string; k:integer; kol:integer);
var k1,k2,c,d,pst,i:integer;
begin
while sekv>0 do begin
k1:=0; k2:=0;
pst:=pos('~',yekv); c:=pst-1; d:=pst+1;
for i:=d to k do
if (copy(yekv,i,1)='~') then begin k2:=i-1; break end
else k2:=k;
if pst=1 then begin
k1:=1;
obj.cells[kol,0]:=obj.cells[kol-1,0]+copy(yekv,k1,k2-k1+1);
delete(yekv,k1,k2-k1+1);
inc(kol); dec(sekv); continue
end else
for i:=c downto 1 do
if (copy(yekv,i,1)='~') then begin k1:=i+1; break; end
else k1:=1;
obj.cells[kol,0]:=copy(yekv,k1,k2-k1+1);
delete(yekv,k1,k2-k1+1);
inc(kol); dec(sekv);
end;
end;