unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Button2: TButton;
Button3: TButton;
OpenDialog1: TOpenDialog;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
filetxt1, filetxt2 : TextFile;
Str1, Str2: string;
begin
Memo1.Clear;
if (Edit1.Text<>'')and(Edit2.Text<>'') then
begin
AssignFile(filetxt1, Edit1.Text);
AssignFile(filetxt2, Edit2.Text);
Reset(filetxt1);
Reset(filetxt2);
while not EOF(filetxt1) do
begin
if EOF(filetxt2)=True then //Periksa apakah file kedua sudah selesai
begin
Memo1.Lines.Add('*** Perhatian ***');
Memo1.Lines.Add('File text Kedua sudah selesai tetapi file text pertama masih ada ada.');
Break;
end;
Readln(filetxt1, Str1);
Readln(filetxt2, Str2);
if CompareStr(Str1, Str2)<>0 then
//Harap diperhatikan fungsi comparestr hanya ada pada versi delphi tinggi pada unit sysutils.
begin
Memo1.Lines.Add('File Pertama - ' + Str1);
Memo1.Lines.Add('File Kedua - '+ Str2);
Memo1.Lines.Add(' ');
end;
end;
if EOF(filetxt2)=False then
begin
Memo1.Lines.Add('*** Perhatian ***');
Memo1.Lines.Add('File pertama telah selesai tetapi file kedua masih ada data.');
end;
CloseFile(filetxt1);
CloseFile(filetxt2);
if Memo1.Lines.Count=0 then
Memo1.Lines.Add('File pertama sama dengan file kedua.');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
Edit1.Text:=OpenDialog1.FileName;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if OpenDialog1.Execute then
Edit2.Text:=OpenDialog1.FileName;
end;
***** SELAMAT MENCOBA *****
Tidak ada komentar:
Posting Komentar