* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
Other / Re: Another new font - IBM Plex
« Last post by mdalacu on Today at 07:26:19 am »
It looks nice the IBM Plex one.
2
Third party / Re: LazProfiler (beta)
« Last post by Pascal on Today at 06:25:57 am »
New release:
LazProfiler 0.1.2.0:
- fixed: checks if backup of source was successfully created before writing instrumented source to original file
3
General / Re: Exception or error flag?
« Last post by Leledumbo on Today at 05:21:38 am »
Both are fine, so long as it is consistent. The benefit of exception is that error handling is made separate from normal flow, with some performance penalty.
4
General / Re: TLazSerial my best option?
« Last post by JonnyMac on Today at 05:12:09 am »
Thanks for the feedback, gentlemen. I realize I'm biting into two apples at once (learning Lazarus and serial coms on a PC-type platform) but it's my nature. My colleague and I (we are www.efx-tek.com) are going to sit through a day of online classes to learn Lazarus this week; that will probably be helpful. That said, I tend to recommend people have an actual project in mind when learning to program the Propeller (which I write about in Nuts & Volts magazine). I'm trying to swallow my own medicine!

Again, thanks for the thoughtful commentary.
5
FPC development / Re: AVR microcontroller unit format
« Last post by engkin on Today at 03:29:52 am »
I have just seen question about usage of volatile in another thread: https://forum.lazarus.freepascal.org/index.php/topic,38961.msg266000.html.

But please....Note volatile in Pascal is just a writable typed const instead of var... Has been since TP days....

Not true.
6
General / Re: Statement as memory barrier for globals ("volatile")
« Last post by engkin on Today at 03:26:13 am »
Does no one have a reference?

I don't think anyone has a reference because it does not exist.

What we can try to do is to test and prove the claims we see here. For instance, someone claimed that "volatile in Pascal is just a writable typed const". So we have to find one example where this claim does not seem to be true:
Code: Pascal  [Select]
  1. program project1;
  2.  
  3. {$mode objfpc}{$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. {$push}{$J+}
  13. const t:integer = 0;
  14. {$pop}
  15. var
  16.   i: integer;
  17. begin
  18.   t := 1;
  19.   i := t;
  20.   i := t;
  21.   i := t;
  22.   i := t;
  23.   i := t;
  24.   i := t;
  25.   i := t;
  26.   i := t;
  27.   i := t;
  28.   i := t;
  29. end.

The compiler (using -O3) emitted the following assembly:
Code: ASM  [Select]
  1. _main:
  2. # Var i located in register eax
  3. # [project3.lpr]
  4. # [18] begin
  5.         call    FPC_INITIALIZEUNITS
  6.         movl    $0,%eax
  7. # [19] t := 1;
  8.         movl    $1,TC_$P$PROJECT1_$$_T
  9. # Var i located in register eax
  10. # [20] i := t;
  11.         movl    $1,%eax
  12. # Var i located in register eax
  13. # [21] i := t;
  14.         movl    $1,%eax
  15. # Var i located in register eax
  16. # [22] i := t;
  17.         movl    $1,%eax
  18. # Var i located in register eax
  19. # [23] i := t;
  20.         movl    $1,%eax
  21. # Var i located in register eax
  22. # [24] i := t;
  23.         movl    $1,%eax
  24. # Var i located in register eax
  25. # [25] i := t;
  26.         movl    $1,%eax
  27. # Var i located in register eax
  28. # [26] i := t;
  29.         movl    $1,%eax
  30. # Var i located in register eax
  31. # [27] i := t;
  32.         movl    $1,%eax
  33. # Var i located in register eax
  34. # [28] i := t;
  35.         movl    $1,%eax
  36. # Var i located in register eax
  37. # [29] i := t;
  38.         movl    $1,%eax

Notice how i := t got optimized to movl $1,%eax

This refutes the claim that writable typed const in Pascal are equivalent to volatile variables in C.

@tetrastes Thanks for the C example.
7
General / Re: TIOBE Index Nov 2017 Delphi/Object Pascal in the Top 10
« Last post by jamie on Today at 02:49:11 am »
I listen to Jimi Hendrix at times, his twisted music reminds me of some code I wrote years ago and
doing a recent review of it, making me wonder where my mind was at the time!
8
General / Re: Exception or error flag?
« Last post by jamie on Today at 02:43:31 am »
It's best to use the standard   TRY, Raise, Exception , Finally etc..

These of course are for cases where errors should not be generated unless due to a
coder error..

 Most coders assumes  any function that receives parameters from a dynamic/Dereference
value that may cause an issue, like divide by 0 for example, is usually encapsulated with a Try and except
statement to catch possible Raise exceptions in functions, for example, a math function you may create and
force it to fault.

 There are times where a complex return type maybe required and thus employment of a record is needed.
In such cases, you can have a Boolean in there to indicate pass or failure.

Btw, Is the Math unit insufficient for your needs?

 I nice DFT and IDFT , FFT would be nice as a stand alone LIB ;)
9
This is curious. I have 1.8RC5 and I have Indy10 installed. If you can, you could try upgrading to 1.8RC5

JD
10
Hi

I created a procedure that does similar,
Not sure how cross-platform it is though.
Code: [Select]
procedure GetControlAsBitmap(AControl :TWinControl;ABitmap:TBitmap);
var
  DC: HDC;
begin
  // quick check to make sure control and bitmap are assigned.
  if not Assigned(ABitmap) then Exit;
  if not Assigned(AControl) then Exit;

  DC :=GetWindowDC(AControl.Handle);
  ABitmap.Width  :=AControl.Width;
  ABitmap.Height :=AControl.Height;
  BitBlt(ABitmap.canvas.Handle,0,0,ABitmap.Width,ABitmap.Height,dc,0,0,SrcCopy);
  ReleaseDC(AControl.Handle, DC);
end;             
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