* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: Mac Address/Printer Status in Linux
« Last post by Jurassic Pork on Today at 01:39:26 pm »
hello,
to have stderr output on command, you can use a TProcess for example like this (to be improved)  :
Code: Pascal  [Select]
  1.  var  hprocess: TProcess;
  2.   OutputLines: TStringList;
  3.   OutputError: TstringList;
  4.  begin
  5.  OutputLines:=TStringList.Create;
  6.  OutputError:=TStringList.Create;
  7.  hProcess := TProcess.Create(nil);
  8.  hProcess.Executable := '/usr/bin/lpq';
  9.  hprocess.Parameters.Add('-l');
  10.  hProcess.Options := hProcess.Options + [poWaitOnExit, poUsePipes];
  11.  hProcess.Execute;
  12.  OutputLines.LoadFromStream(hprocess.Output);
  13.  OutputError.Add('Error :');
  14.  OutputError.LoadFromStream(hProcess.Stderr);
  15.  if OutputError.Text <> '' then showMessage(OutputError.Text)
  16.  else     ShowMessage(OutputLines.Text);
  17.  hProcess.Free;
  18.  OutputLines.Free;
  19.  Outputerror.Free;
  20.  end;
if you have CUPS as printing daemon and you want a printer, you can install printer-driver-cups-pdf
(printer driver for PDF writing via CUPS).

Friendly, J.P
2
General / Re: My bug or rtl bug with TThread and TThreadList?
« Last post by Thaddy on Today at 12:38:33 pm »
Yeah, I have doubts on how thread safe writeln is too.
It isn't. At least, not in 3.0.2 on windows. No reason to panic though, just garbled output and/or output in wrong order.

See also logger attachment with example in this post. (sorry for the faulty critical section: there should be as many as there are calls to writeln or code should be re-arranged to have only one overloaded function that actually calls writeln).

Just remove/comment the threadsafe define and run the example a couple of times to see where/how things go wrong.
thank you. I missed that post. I'll take a closer look tomorrow night.

Note on windows it is not threadsafe, but it is on linux, bsd and mac. Windows has just one *1* console. But there is code around that mitigates this (I use the code by Barry Kelly)
3
Mac OS X / Re: Debugging the Lazarus IDE on Mac
« Last post by JuhaManninen on Today at 12:28:10 pm »
Presumably, I would need to go to `Tools -> Configure "Build Lazarus"` and select the `Debug` option. If so, would I need to set any other options, and can I do it in such a way as to avoid affecting my existing Lazarus build?
I don't know about Mac but on Linux the debugging of Lazarus using another instance of Lazarus works well. Console gdb works, too.
Don't choose another folder. Just build the Debug IDE into the same directory. You can copy backup binaries as much as needed in the same or into another folder. A backup binary is recommended anyway in case you modify the IDE's code so it crashes. Then just start the other binary and continue.
To debug with another instance of Lazarus, open project "lazarus.lpi" and press F9.
"lazarus.lpi" cannot be used for building the IDE because it not yet a "normal" project, but it is good for debugging.
4
General / Re: Mac Address/Printer Status in Linux
« Last post by Leledumbo on Today at 11:49:28 am »
I tried using RunCommand('lpq', myString), but it results in an empty string. I currently do not have any installed/connected printer. Is this why it's empty?
Yes, without any printers installed, it will only output error message to stderr, which runcommand doesn't capture (internally it does, but it's not exposed to caller).
5
Cocoa / Re: Is Cocoa the future for Lazarus on macOS?
« Last post by GillesH on Today at 11:21:54 am »
Hello,

4: OK. Aside from a font problem in the windows  (screenshot), Lazarus works normally (including the reported slowness that no longer exists). GDB is operational.

I can recompile it with the default settings from the IDE itself so I can integrate my own components.

But, the default configuration is i386 and not x86_64 and any attempt with this option fails.

Regards. Gilles
6
Third party / Re: Fpcupdeluxe
« Last post by josh on Today at 09:47:09 am »
Hi

Just tried to update Trunk ( win 32 version) installation, and getting error.
Code: [Select]
(3104) Compiling .\win32\win32wscalendar.pp
(3104) Compiling .\win32\win32wschecklst.pp
(3104) Compiling .\win32\win32wsstdctrls.pp
(3104) Compiling .\win32\win32wscomctrls.pp
(3104) Compiling .\win32\win32wsdialogs.pp
C:\lazarus_trunk\lazarus\lcl\interfaces\.\win32\win32wsdialogs.pp(770,62) Error: (4001) Incompatible types: got "Pointer" expected "TGuid"
win32wsdialogs.pp(1530) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: C:\lazarus_trunk\fpc\bin\i386-win32\ppc386.exe returned an error exitcode
Error: (lazarus) Compile package LCL 1.9: stopped with exit code 1
Error: (lazarus) [TLazPackageGraph.CompileRequiredPackages] "Exit code 1"

looks like something has changed in Trunk
7
General / Re: A stubborn edit box
« Last post by katfo on Today at 08:57:01 am »
Thank you all for your help. I switched to version 1.6.4 and everything seems to work now as it should.
8
General / Re: Controlling 3 Forms Correctly
« Last post by mangakissa on Today at 08:26:32 am »
Put unit2 and unit3 in the uses of unit1 under implementation
Code: Pascal  [Select]
  1. implementation
  2.    uses unit2, unit3;
  3.  
Use property show instead of showmodal
9
General / Re: Controlling 3 Forms Correctly
« Last post by RAW on Today at 06:16:12 am »
I don't think this makes a lot of sense, but it does what you ask for...

Unit1:
Code: Pascal  [Select]
  1. UNIT Unit1;
  2.  {$MODE OBJFPC}{$H+}{$J-}
  3.  
  4. Interface
  5.  USES
  6.   Classes, SysUtils, Forms, Controls, StdCtrls;
  7.  
  8.  TYPE
  9.   TForm1 = Class(TForm)
  10.  
  11.    Button1: TButton;
  12.  
  13.    Procedure FormCreate   (Sender: TObject);
  14.    Procedure Button1Click (Sender: TObject);
  15.   End;
  16.  
  17.  VAR
  18.   Form1: TForm1;
  19.  
  20. Implementation
  21.  {$R *.LFM}
  22.  USES Unit2;
  23.  
  24.  
  25. Procedure TForm1.FormCreate(Sender: TObject);
  26.  Begin
  27.   Caption:= 'Window 1';
  28.  
  29.   SetBounds((Screen.WorkAreaWidth -500) Div 2,
  30.             (Screen.WorkAreaHeight-300) Div 2,
  31.              500, 300);
  32.  
  33.   Constraints.MinHeight:= 300;
  34.   Constraints.MaxHeight:= 300;
  35.   Constraints.MinWidth := 500;
  36.   Constraints.MaxWidth := 500;
  37.  End;
  38.  
  39.  
  40. Procedure TForm1.Button1Click(Sender: TObject);
  41.  Begin
  42.   If Not Assigned(Form2)
  43.   Then
  44.    Begin
  45.     Form2:= TForm2.Create(Application);
  46.     Form2.ShowInTaskBar:= stAlways;
  47.     Form2.Show;
  48.     Form1.Hide;
  49.    End
  50.   Else
  51.    Begin
  52.     Form2.Show;
  53.     Form2.BringToFront;
  54.     Form1.Hide;
  55.    End;
  56.  End;
  57.  
  58. END.

Unit2:
Code: Pascal  [Select]
  1. UNIT Unit2;
  2.  {$MODE OBJFPC}{$H+}{$J-}
  3.  
  4. Interface
  5.  USES
  6.   Classes, SysUtils, Forms, Controls, StdCtrls;
  7.  
  8.  TYPE
  9.   TForm2 = Class(TForm)
  10.  
  11.    Button1: TButton;
  12.  
  13.    Procedure FormCreate   (Sender: TObject);
  14.    Procedure Button1Click (Sender: TObject);
  15.    Procedure FormClose    (Sender: TObject; Var CloseAction: TCloseAction);
  16.  
  17.   End;
  18.  
  19.  VAR
  20.   Form2: TForm2;
  21.  
  22. Implementation
  23.  {$R *.LFM}
  24.   USES Unit3;
  25.  
  26. Procedure TForm2.FormCreate(Sender: TObject);
  27.  Begin
  28.   Caption:= 'Window 2';
  29.  
  30.   SetBounds((Screen.WorkAreaWidth -500) Div 2,
  31.             (Screen.WorkAreaHeight-300) Div 2,
  32.              500, 300);
  33.  
  34.   Constraints.MinHeight:= 300;
  35.   Constraints.MaxHeight:= 300;
  36.   Constraints.MinWidth := 500;
  37.   Constraints.MaxWidth := 500;
  38.  End;
  39.  
  40.  
  41. Procedure TForm2.Button1Click(Sender: TObject);
  42.  Begin
  43.   If Not Assigned(Form3)
  44.   Then
  45.    Begin
  46.     Form3:= TForm3.Create(Application);
  47.     Form3.ShowInTaskBar:= stAlways;
  48.     Form3.Show;
  49.     Form2.Hide;
  50.    End
  51.   Else
  52.    Begin
  53.     Form3.Show;
  54.     Form3.BringToFront;
  55.     Form2.Hide;
  56.    End;
  57.  End;
  58.  
  59.  
  60. Procedure TForm2.FormClose(Sender: TObject; Var CloseAction: TCloseAction);
  61.  Begin
  62.   Application.Terminate;
  63.  End;
  64.  
  65. END.

Unit3:
Code: Pascal  [Select]
  1. UNIT Unit3;
  2.  {$MODE OBJFPC}{$H+}{$J-}
  3.  
  4. Interface
  5.  USES
  6.   Classes, SysUtils, Forms, Controls, StdCtrls;
  7.  
  8.  TYPE
  9.   TForm3 = Class(TForm)
  10.  
  11.    Button1: TButton;
  12.  
  13.    Procedure FormCreate   (Sender: TObject);
  14.    Procedure Button1Click (Sender: TObject);
  15.    Procedure FormClose    (Sender: TObject; Var CloseAction: TCloseAction);
  16.  
  17.   End;
  18.  
  19.  VAR
  20.   Form3: TForm3;
  21.  
  22. Implementation
  23.  {$R *.LFM}
  24.   USES Unit1;
  25.  
  26.  
  27. Procedure TForm3.FormCreate(Sender: TObject);
  28.  Begin
  29.   Caption:= 'Window 3';
  30.  
  31.   SetBounds((Screen.WorkAreaWidth -500) Div 2,
  32.             (Screen.WorkAreaHeight-300) Div 2,
  33.              500, 300);
  34.  
  35.   Constraints.MinHeight:= 300;
  36.   Constraints.MaxHeight:= 300;
  37.   Constraints.MinWidth := 500;
  38.   Constraints.MaxWidth := 500;
  39.  End;
  40.  
  41.  
  42. Procedure TForm3.Button1Click(Sender: TObject);
  43.  Begin
  44.   Form1.Show;
  45.   Form1.BringToFront;
  46.   Form3.Hide;
  47.  End;
  48.  
  49.  
  50. Procedure TForm3.FormClose(Sender: TObject; Var CloseAction: TCloseAction);
  51.  Begin
  52.   Application.Terminate;
  53.  End;
  54.  
  55. END.

LPR MainProgram:
Code: Pascal  [Select]
  1. PROGRAM Project1;
  2.  {$MODE OBJFPC}{$H+}{$J-}
  3.  
  4.  USES
  5.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  6.    cThreads,
  7.   {$ENDIF}{$ENDIF}
  8.    Interfaces,
  9.    Forms,
  10.    Unit1, Unit2, Unit3;
  11.  
  12.   {$R *.RES}
  13.  
  14. BEGIN
  15.  RequireDerivedFormResource:= True;
  16.   Application.Title:= 'Main Form';
  17.   Application.Initialize;
  18.   Application.CreateForm(TForm1, Form1);
  19.   Application.Run;
  20. END.
10
General / Re: Controlling 3 Forms Correctly
« Last post by RAW on Today at 03:51:15 am »
You can load only one form and show complete different things on that second form depending on the button you pressed for example.
Of course you can load a lot of forms at the same time and show everything at the same time...
As I said there are thousand ways of doing something...

What is shown on the forms or should be shown on the forms ???
Pages: [1] 2 3 ... 10

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus