Mantixd,
Cita:
|
Empezado por Mantixd
...como puedo comparar el texto de 2 memos y mandar a 1 tercer memo el texto diferente...
|
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Memo3: TMemo;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
L1, L2 : String;
Pos : Integer;
begin
Memo3.Clear;
for i := 0 to Memo1.Lines.Count - 1 do
begin
L1 := Memo1.Lines.Strings[i];
L2 := Memo2.Lines.Strings[i];
Pos := AnsiPos(L1,L2);
if (Pos > 0) then
Delete(L2,Pos,Length(L1));
Memo3.Lines.Add(TrimLeft(L2));
end;
end;
end.
El código anterior en Delphi 7 bajo Windows 7 Professional x32,
compara línea a línea el texto de TMemo1 con TMemo2 y guarda en TMemo3 el diferencial de TMemo2 menos TMemo1, como se muestra en la imagen:
Espero sea útil
Nelson.