Recent

Author Topic: Tmemo Scrolling old data  (Read 273 times)

chucky

  • New Member
  • *
  • Posts: 42
Tmemo Scrolling old data
« on: October 06, 2025, 08:11:01 pm »
I want to use a TMemo to save log information, but I want to limit the size. I thought setting the MaxLength property would do the trick by dropping the old data and appending the new string, but instead it just quits logging.

Can someone tell me how to get TMemo to do that?

cdbc

  • Hero Member
  • *****
  • Posts: 2477
    • http://www.cdbc.dk
Re: Tmemo Scrolling old data
« Reply #1 on: October 06, 2025, 08:50:56 pm »
Hi
Try this:
Code: Pascal  [Select][+][-]
  1. type
  2.   TForm1 = class(TForm)
  3.     Memo1: TMemo;
  4.     ...
  5.   private
  6.     fMaxLogLn: cardinal;
  7.     procedure LogLn(const aStr: string);
  8.     ...
  9.     property MaxLogLines: cardinal read fMaxLogLn write fMaxLogLn;
  10.   end;
  11. /// - - - - - - - - ///
  12. procedure TForm1.LogLn(aStr: string);
  13. begin
  14.   Memo1.Append(aStr);
  15.   if Memo1.Count >= fMaxLogLn then Memo1.Lines.Delete(0);
  16. end;
  17.  
That should do the trick  :D
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6 -> FPC 3.2.2 -> Lazarus 4.0 up until Jan 2025 from then on it's both above &: KDE6/QT6 -> FPC 3.3.1 -> Lazarus 4.99

 

TinyPortal © 2005-2018