Recent

Author Topic: [SOLVED] Remove x number of lines from start of TMemo  (Read 2860 times)

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
[SOLVED] Remove x number of lines from start of TMemo
« on: January 15, 2015, 03:53:03 pm »
 0 down vote favorite
   

I'm using a TMemo in Lazarus to display a rolling log, but I want to limit it to the last 500 entries.

What I'd like to do is (in pseudo-code):

Code: [Select]
if (log_TMemo.Lines.Count > 500) then
   log_TMemo.Lines := log_TMemo[LinesCount - 500 to LinesCount];

TMemo contains TStrings TMemo.Lines, so I guess a want a way to copy a subset of the TStrings array.

Is there a way to do this, or is there another way to achieve a max number of lines in a TMemo?

-FM
« Last Edit: January 15, 2015, 06:22:29 pm by fatmonk »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Remove x number of lines from start of TMemo
« Reply #1 on: January 15, 2015, 04:50:31 pm »
Code: [Select]
  while log_TMemo.Lines.Count do
    log_TMemo.Lines.Delete(0);

Bart

  • Hero Member
  • *****
  • Posts: 5573
    • Bart en Mariska's Webstek
Re: Remove x number of lines from start of TMemo
« Reply #2 on: January 15, 2015, 04:52:12 pm »
You meant obviously:

Code: [Select]
  while log_TMemo.Lines.Count > 500 do
    log_TMemo.Lines.Delete(0);

Bart

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: Remove x number of lines from start of TMemo
« Reply #3 on: January 15, 2015, 06:22:00 pm »
That's a nice simple way to do it, ta.  :)

-FM

 

TinyPortal © 2005-2018