Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: storing string
« Last post by ASerge on Today at 11:06:57 pm »
I don't really like all the solutions from above.
It takes a lot of effort to figure out why it works.
And repeated conversions of types.
In some solutions, they forgot about freeing up memory, apparently they tested it only on constants.
In my opinion, there is already a container for strings, it's easy enough to use it:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, StdCtrls;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     Button1: TButton;
  13.     Button2: TButton;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure Button2Click(Sender: TObject);
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure FormDestroy(Sender: TObject);
  18.   private
  19.     FTagHolder: TStringList;
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.lfm}
  30.  
  31. { TForm1 }
  32.  
  33. procedure TForm1.Button1Click(Sender: TObject);
  34. begin
  35.   Button1.Tag := FTagHolder.Add('Some string');
  36. end;
  37.  
  38. procedure TForm1.Button2Click(Sender: TObject);
  39. begin
  40.   Caption := FTagHolder[Button1.Tag];
  41. end;
  42.  
  43. procedure TForm1.FormCreate(Sender: TObject);
  44. begin
  45.   FTagHolder := TStringList.Create;
  46. end;
  47.  
  48. procedure TForm1.FormDestroy(Sender: TObject);
  49. begin
  50.   FTagHolder.Free;
  51. end;
  52.  
  53. end.
2
Might you possibly be having a version of your script that installs the Qt5 version of Lazarus, instead of the GTK2 version?
My RPI4 just became available again today so I can check on that tomorrow.

(Last time I checked I thought it was automatic but I'll have to check)
3
Beginners / Re: pointer to out of scope const
« Last post by Joanna from IRC on Today at 10:26:18 pm »
That’s interesting. So the constant inside a procedure exists for the life of the program execution. That explains it. Thanks .
Note that depending on the setting of the $J directive that "constant" may be a variable (writable constant)
I  assume that this directive only applies to typed. Constants?
4
General / Re: Benchmarks
« Last post by alpine on Today at 10:24:55 pm »
I have learned something today - a recursive function can be inlined. That's simply amazing!
You can see the optimizations that FPC supports in the documentation: https://www.freepascal.org/docs-html/prog/progsu58.html#x65-640001.2.58

As you can see it can optimize tail recursion, meaning a function where the result is computed by with a final function call, can be converted into non recursive code.
Not a tail recursion.
5
General / Re: Bright color
« Last post by wp on Today at 10:24:04 pm »
In unit GraphUtil:
Code: Pascal  [Select][+][-]
  1. function GetHighLightColor(const Color: TColor; Luminance: Integer = 19): TColor;
  2. function GetShadowColor(const Color: TColor; Luminance: Integer = -50): TColor;
6
General / Re: Benchmarks
« Last post by alpine on Today at 10:23:09 pm »
I have learned something today - a recursive function can be inlined. That's simply amazing!

Sarcasm? :D It is inlined, in the loop
Not at all. I've already examined the assembly. Each inner call is inlined exactly twice, which is actually a real benefit.
7
General / Re: Benchmarks
« Last post by Warfley on Today at 10:17:29 pm »
I have learned something today - a recursive function can be inlined. That's simply amazing!
You can see the optimizations that FPC supports in the documentation: https://www.freepascal.org/docs-html/prog/progsu58.html#x65-640001.2.58

As you can see it can optimize tail recursion, meaning a function where the result is computed by with a final function call, can be converted into non recursive code.
8
Suggestions / Re: Show Form at Top
« Last post by n7800 on Today at 10:16:21 pm »
There was an issue on the bug tracker that touched on this topic, whether to show a Designer when selecting a component in the Component List (like the Component Palette does), or not. I wasn't sure if it was necessary, since the window is different from the toolbar, but now I decided to write a patch. See the merge request for details.
9
General / Re: Benchmarks
« Last post by Fibonacci on Today at 10:14:10 pm »
I have learned something today - a recursive function can be inlined. That's simply amazing!

Sarcasm? :D It is inlined, in the loop
10
BTW. Can you check if this gives the same directory?
(I could use this in the script instead of find)

Code: Bash  [Select][+][-]
  1. dirname $(gcc --print-file-name=crtbegin.o)

/edit/
Ok, I changed this in my script and it seems to take the correct gcc lib directory.

Code: Bash  [Select][+][-]
  1. cat << EOF >> $HOME/.fpc.cfg
  2. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget
  3. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/*
  4. -Fu$BASE/fpc/lib/fpc/\$fpcversion/units/\$fpctarget/rtl
  5. -Fl$(dirname $(gcc --print-file-name=crtbegin.o))
  6. -FD$BASE/fpc/bin
  7. EOF

On to my next issue - investigating why closing common file dialogs now, causes crashes on Qt5 x86_64 Linux operating systems (reproduced on Centos 9 and Fedora 40 thus far).

Might you possibly be having a version of your script that installs the Qt5 version of Lazarus, instead of the GTK2 version?
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018