I got it displayed but the memo dosn't scroll. Why? I used ssAutoBoth and ssAutoVertical:
//Processandwait example by Amnon82
//Version 20070312-1
//
//Create a form with one button on it.
//Copy this sourcecode to your pas.
//Compile it in lazarus.
unit unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons, Process,
StdCtrls, DbCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
DBMemo1: TDBMemo;
Edit1: TEdit;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure Processandwait(Executable : String);
var
AProcess1: TProcess;
exitcode, i : integer;
AStringList: TStringList;
begin
I:= 0;
AStringList := TStringList.Create;
try
AProcess1 := TProcess.Create(nil);
AProcess1.CommandLine := Executable;
AProcess1.Options := AProcess1.Options+ [poUsePipes];
{Execute}
AProcess1.Execute;
{Wait to finish}
while AProcess1.running = true do
begin
form1.button1.enabled:=false;
//I:= I + 1;
AStringList.LoadFromStream(AProcess1.Output);
if form1.radiobutton2.checked= true
then
Form1.dbmemo1.lines.add(Astringlist.text)
else
form1.edit1.text:=Astringlist.text;
sleep (400);
Application.ProcessMessages;
end;
finally
AStringList.LoadFromStream(AProcess1.Output);
if form1.radiobutton2.checked=true
then
Form1.dbmemo1.lines.add(Astringlist.text);
AProcess1.Free;
AStringlist.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if radiobutton2.checked=true then
Processandwait('sudo ./copypaldo.sh')
else
Processandwait('sudo ./gettable2.sh') ;
button1.enabled:=true;
showmessage('done');
end;
initialization
{$I unit1.lrs}
end.