Displaying progress of shell messages in a memo - how? lazarus / 13-General ---------------------------------------------------------------------- Amnon82 · 2007-04-01 11:29 I'm writing an installer for a linux distribution. I'm running sh-scripts for coping files. Now I want to display the progress of the running sh-script in a memo or listbox. For doing that I need a function to display the GUI messages without freezing the GUI. What will the best way to do that? ---------------------------------------------------------------------- Amnon82 · 2007-04-01 14:20 The freezing I solved in this code: Code: [Select]//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; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     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; begin   I:= 0;   try   AProcess1 := TProcess.Create(nil);   AProcess1.CommandLine := Executable;   AProcess1.Options := AProcess1.Options;  {Execute}   AProcess1.Execute;   {Wait to finish}   while AProcess1.running = true do   begin   I:= I + 1;   sleep (300);   form1.caption :=  ' L:'+ inttostr(i);    Application.ProcessMessages;   end;   finally     AProcess1.Free;     end; end; procedure TForm1.Button1Click(Sender: TObject); begin  Processandwait('gedit');  Showmessage('gedit closed'); end; initialization   {$I unit1.lrs} end.     now I must find a way to get the messages of the external app into a memo/listbox. ---------------------------------------------------------------------- theo · 2007-04-01 14:35 Have you seen the Wiki pages? http://wiki.lazarus.freepascal.org/Executing_External_Programs ---------------------------------------------------------------------- Amnon82 · 2007-04-01 15:12 I readed it. I need a option to display the progress of unsquashing a image in a memo. So it must be displayed during the excution. ---------------------------------------------------------------------- Amnon82 · 2007-04-01 16:55 I got it displayed but the memo dosn't scroll. Why? I used ssAutoBoth and ssAutoVertical: Code: [Select]//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.