Yeah, I posted only a part of the code with the new function - so the "uses" is something I should have added.
That's why I wrote it in the code comments that the function came from dateutils
.
Glad to hear it worked out with incMillisecond
Haha, yeah working with code written by others is a challenge at times, let alone when they leave out comments. I run into that every now and then as well. The last time I worked with assembler was on a Commodore Amiga (Motorola 68000). I may have done an attempt to do assembler on an Intel 386, but quickly ran away screaming hahaha.
I wouldn't say that Lazarus is more top heavy, maybe for really small applications. But as applications get bigger, the size of the application will increase much less than Delphi. The turning point for me (I started with Delphi 1.0 and used it up to Delphi 2006) was when I noticed how much faster Lazarus applications can be, compared to Delphi (at the time - I'm sure Delphi has improved in the meanwhile). Another thing where Delphi lost me is the use of FireMonkey instead of VLC, and the fact that MacOS and iOS 64 bit is not (yet) supported. I'm not a fan of custom drawn controls - I prefer native controls.
But time will tell if I will switch back or not - I do keep testing Delphi every now and then to see where they are at.
For now I'm very happy with Lazarus
(you'll see that all my applications on this website are written in Lazarus).
Sounds like you're indeed getting your feet wet with Lazarus - very cool!
And you'll notice it works a little bit different than Delphi or Turbo Pascal (at least that was my experience).
Units that are not used;
First thing is to realize is that if a file is open in Lazarus, then this does not mean the file is part of your project perse.
When debugging or looking for the declaration of a function, Lazarus can open a Lazarus Pascal unit (for example control.inc, brush.inc and Graph).
This does not mean it's now a "fixed" part of your project. So you can close those without worry.
Next, I'd first check which units are marked as required in your project file (menu: Project -> Project Inspector).
Remove the files you don't need - for example your unit2 and unit3 could be in there by mistake and therefore can be removed.
I also tend to clean up (remove) files from the project directory when I do not need them anymore (just to clean up) - sometimes by moving them in a separate sub directory, just so they stay handy in case I made a mistake in removing the files. For example, you probably opened "testtimer" to review your old code, I do this often as well, but since it's not part of your project, you can close the file and/or move the file to the backup directory (or leave it where it was, in case it was located not located in your project directory).
Note: For testing I usually start a small separate project.
Once done testing I copy the parts of the code that I need to my main unit (or a separate unit).
The file "NEW_fieldst.lpr" is a project file (Lazarus PRoject).
A project file is the main file, holding it all together, like DPR files in Delphi.
You can close this file, it's not often that you need to be in that file, but it is part of your project.
Delay in refreshing painting
Lazarus Pascal appears highly optimized, especially compared to Delphi.
This does occasionally come with little challenges like this one.
Coming back to your code; you'll need to give the application some breathing room in the repeat-until loop.
You can do this by adding "Application.Processmessages" (recommended) and/or a little sleep like sleep(100) or something like that (I believe that using sleep() is frowned upon
). LCL (Lazarus VCL counterpart) handles a lot through messaging (probably inherited from the original Delphi 7.x / Windows). ProcessMessages briefly jumps to the mechanism that handles these messages - repainting an control could be one of those messages.
Since I already delete the project file, you could give this a try - I haven't tested it.
procedure TForm1.Button1Click(Sender: TObject);
var
Start_Time, Inter_Time, Lapse_time, Del_Dot_Wait : qword;
begin
Shape2.left := 200;{}
Del_Dot_Wait := 10000;
Start_Time := GetTickCount64();
Repeat
application.ProcessMessages; // <-- process LCL messages
Inter_Time := GetTickCount64();
Lapse_Time := Inter_time-Start_time;
Until Lapse_time > Del_Dot_Wait;
Shape2.left := 10;
end;
Feel free to ask - I'd be happy to help. Always nice to see other Lazarus Developers here