unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Edit2: TEdit;
    Panel1: TPanel;
    Edit1: TEdit;
    Button2: TButton;
    Button3: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Edit2KeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}


procedure MyLineOut(s: string); // Output procedure
begin
  form1.memo1.lines.add(s);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  RC_LineOut:=MyLineOut; // set Output
  edit2.align:=albottom;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  RC_Run(Edit1.text); // run console program
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  RC_LineIn('exit');
  Close;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
const EnterKey=#13; NoKey=#00;
begin
  if key=EnterKey then begin // send command line on Enter Key
    RC_LineIn(edit2.text);
    edit2.text:='';
    key:=NoKey;
  end;
end;

end.
