unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  AHMSystemClass, AHMTTextReplace, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    AHMTextReplace1: TAHMTextReplace;
    Memo1: TMemo;
    Memo2: TMemo;
    Panel1: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure AHMTextReplace1BeforeWrite(Sender: TObject; var Line: String;
      LineNo: Integer; var WriteLine: Boolean);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.AHMTextReplace1BeforeWrite(Sender: TObject;
  var Line: String; LineNo: Integer; var WriteLine: Boolean);
Var AtPos : Integer;
begin
  if LineNo>4 then exit;
  {Find the position of the @ sign}
  AtPos:=Pos('@',Line);
  {delete everything after that until the dot}
  Delete(Line,AtPos+1,Pos('.',Line)-AtPos-1);
  {Insert the new domainname for this example}
  Insert(Edit1.Text,Line,AtPos+1);
  WriteLine:=True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if FileExists(ExtractFilePath(Application.ExeName)+'\Output.tst') then
  Memo2.Lines.LoadFromFile(ExtractFilePath(Application.ExeName)+'\Output.tst');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if FileExists(ExtractFilePath(Application.ExeName)+'\Example.tst') then
Memo2.Lines.LoadFromFile(ExtractFilePath(Application.ExeName)+'\Example.tst');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  AHMTextReplace1.Execute;
  Button2Click(Self);
end;

end.
