* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: Programatically open a link in fpCEF3
« Last post by mhoude on Today at 02:56:31 am »
I moved to Qt.

Thanks anyway.
2
General / Re: Any TStringBuilder class implementation?
« Last post by dmz73 on Today at 02:51:16 am »
Originally it was of course just for working around the Java/.NET limitation that strings are immutable.

The only thing I can imagine for implementations without immutable strings is  that you program against an interface that you could replace with something else, to have better control over the algorithm to reallocate the buffer during repeated (and prolonged) concatenation. (read webidiots that append MB's of javascript gibberish)

The advantage of TStringBuilder is that is allocates additional memory for the string so it reduces the number of string copy operations when reallocating the string memory on append of new string. Speed difference becomes noticeable once memory manager can no longer expand the existing string without making a copy first.
It is difficult to create a simple test to show this issue with but I have seen it in XML parser when assembling XML text from nodes on large XML documents and also recently in jedicodeformat when processing a large .PAS file. In both cases replacing the simple "outputstring := outputstring + smallstring" with TStringBuilder increased the speed by several orders of magnitude.

I have implemented the methods of TStringBuilder class started by tangentstorm on github (https://github.com/tangentstorm/fpc-stringbuilder) in my fork here https://github.com/dmz73vu/fpc-stringbuilder.
3
This common Indy problem has popped up again for me with Lazarus 1.8 RC2...

Not sure what is going on, but my first instinct is that you have multiple versions of IdGlobal on your system, and the wrong one is being found during installation.  You might try using SysInternals Process Monitor to see what files are actually being touched during compiling and installation.
4
Other / Re: Strange compiler behavior with generics [BUG?]
« Last post by soerensen3 on Today at 02:03:28 am »
Just to show that it is possible to do something like multiple inheritance with generics run this code and have a look at the output.
Code: Pascal  [Select]
  1. program Project1;
  2. {$APPTYPE CONSOLE}
  3. {$mode delphi}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Classes
  10.   { you can add units after this };
  11.  
  12. type
  13.  
  14.   { TShowClassParents }
  15.  
  16.   TShowClassParents < T: class > = class ( T )  //generic that shows class parents
  17.     procedure WriteClassParents;
  18.   end;
  19.  
  20.   { TNamedObject }
  21.  
  22.   TNamedObject < T: class > = class ( T ) //generic with a name field
  23.     private
  24.       FName: String;
  25.  
  26.     public
  27.       property Name: String read FName write FName;
  28.   end;
  29.  
  30.  
  31. procedure TShowClassParents < T >.WriteClassParents;
  32. var
  33.   c: TClass;
  34. begin
  35.   c:= ClassType;
  36.   while Assigned ( C ) do // This will loop through all class parents and write them to the output
  37.     begin
  38.       WriteLn( C.ClassName );
  39.       c:= c.ClassParent;
  40.     end;
  41. end;
  42.  
  43. type
  44.   //predeclare types as specializations cannot be passed as a parameter directly
  45.   TListShowParents = TShowClassParents < TList >; //A list with the WriteClassParents method
  46.   TNamedList = TNamedObject < TList >; //A List with a name field
  47.  
  48. var
  49.   Ob: TShowClassParents < TPersistent >; // A persistent with the WriteClassParents method
  50.   Ob2: TNamedObject< TListShowParents >; // "Multiple inherit" first inherit TListShowParent then inherit TNamedObject
  51.   Ob3: TListShowParents< TNamedList >; // Do it the other way around
  52.  
  53. begin
  54.   WriteLn( 'Class parents of Ob' );
  55.   Ob:= TShowClassParents < TPersistent >.Create;
  56.   Ob.WriteClassParents;
  57.   Ob.Free;
  58.  
  59.   WriteLn;
  60.  
  61.   WriteLn( 'Class parents of Ob2' );
  62.   Ob2:= TNamedObject < TListShowParents >.Create;
  63.   Ob2.WriteClassParents;
  64.   Ob2.Free;
  65.  
  66.   WriteLn;
  67.  
  68.   WriteLn( 'Class parents of Ob3' );
  69.   Ob3:= TShowClassParents < TNamedList >.Create;
  70.   Ob3.WriteClassParents;
  71.   Ob3.Free;
  72. end.
  73.  

You can see that this is possible in Free Pascal even with Delphi Mode. I don't have Delphi so I cannot test it there.

But in a generic like this I cannot inherit virtual methods from a base class. I think there is the compiler bug. That it complaints that the base class does not have this method at all while in the above case where no method is overridden it just compiles.
5
General / Re: Code compile in Delphi but not in Lazarus
« Last post by Remy Lebeau on Today at 02:00:20 am »
Code: Pascal  [Select]
  1.  Inc(Info.Level);  

Code: Pascal  [Select]
  1.  Dec(Info.Level);  

both lines same error: Error: Illegal qualifier

Hmm, that means there is a naming conflict with something else in the code.  I have tweaked the variable names to help avoid that.

Nevermind because with the {$Mode Delphi} compiles fine with 3 warnings: Hint: Conversion between ordinals and pointers is not portable

It is not portable.  But as long as the ordinal is the same size as a pointer (which LPARAM should be), it is fine.
6
General / Re: Need some Help for RightToLeft TWinControls
« Last post by majid.ebru on Today at 01:33:38 am »
Thank you
7
Portuguese / Re: thread
« Last post by kapibara on Today at 12:47:52 am »
Você precisa disso no laço. Ou então, o loop roubará todo o poder da janela principal e o showmessage não será exibido até que o loop termine.

Code: Pascal  [Select]
  1. Sleep(1);

Olhe para demonstração..

He asked:

"I followed your video and did exactly as in the video, but my thread does not work.
It does not generate any errors, simply the showmessage appears only after the thread completes.
I'm using win10 64bit and Lazarus 1.6.4
What happens?"

And I said: You need this in the loop. Or else the loop will steal all power from the main window, and showmessage won't be showed until the loop ends.
8
Portuguese / Re: thread
« Last post by JD on Today at 12:27:20 am »
I stopped watching after about three seconds because it looks like BASIC:
- Everything is UPPERCASED...
- And you count from 1... Real programmers count from zero  8-)

Nice try! Video is of good quality, but you can skip a bit.

 :D :D :D :D :D
9
General / Re: The future of Free Pascal
« Last post by jc99 on Today at 12:25:23 am »
Whenever i change the Textfile I had to Change the number of the Array too, and I Sooooooooo didn't liked that !!!!!

The problem is the whole "copy and paste in source" idea driven too far, a different solution would be to use resources.

I had the same problem with shader source code (not being recompiled after run), changed to resources and am very happy with it.
I also had resource in mind, but in this special case it had to be a hard-coded Array of Strings coming from an include-file.
10
General / Re: The future of Free Pascal
« Last post by jc99 on Today at 12:21:51 am »
Or the second Code: you only have to write a vararray to TmyPoint-conversion and overload the assignment operator then 

And array only. Though maybe you can work around it with some conversion operator. (e.g. from array of two singles to tpoint etc)
Sorry, I meant conversion operator of cause. from array to TMyPoint
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