Solved

How many strings can a memo hold?

Posted on 2001-06-07
9
192 Views
Last Modified: 2010-04-06
Hi All,

I have D4 and win2000NT. I want to store data (strings) in a memo. The strings are less 100
letters long and  always starting from the left. Some programmers put a limit on the number of
strings displayed this way before doing a delete to provide for  new incoming strings.
as in (snip)

   while Memo1.Lines.Count > 500 do
      Memo1.Lines.Delete(0);

But  in my case I need all of the strings that were sent from top to bottom once the delivery
 is completed and it could be substanilly more than 500.

Any suggestions for an efficient way to accomplish this? The number to lines can be greater
than the number shown above in the snip.

Delphi3
0
Comment
Question by:delphi3
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 5

Expert Comment

by:knowlton
ID: 6164172
Perhaps you could store the string in a TStringList first, then display the strings in the TMemo as needed.

Tom
0
 
LVL 17

Expert Comment

by:geobul
ID: 6164251
Hi,
TMemo can hold up to 64K and there is no line number limit. You have to check Length(memo1.Lines.text)) and if it goes near 60K, delete some lines.

Regards, Geo
0
 
LVL 6

Expert Comment

by:edey
ID: 6164531
actually, just to clarify, there is an upper line count limit. 65536 char's divided by 2 chars (#10#13) gives you 32768 lines :)

Seriously, though, while the length of aTMemo is limited to a 16bit value, a TRichEdit has a 32bit limit (>4,000,000,000 chars).  While the helps says that the maxlength property can be set to 0 for large files, you actually need to set to a large value or it will be limited to 64k too.

GL
Mike
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 17

Expert Comment

by:geobul
ID: 6166797
Hi Mike,
Theoretically you are right but in reality you cannot add more than 10765 empty lines in a memo (tested on D3 and D5). Strange, isn't it?

Regards, Geo
0
 
LVL 6

Expert Comment

by:edey
ID: 6168335
Want to see something really strange? Try inserting lines of 0, 1, 2, 3 etc chars.  I tried inserting lines of spaces & got these results:

0 chars: 10756 lines
1 chars:  6951 lines
2 chars:  6981 lines
3 chars:  6519 lines
4 chars:  5359 lines

not eve a linear relationship.  Strange.

GL
Mike
0
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
ID: 6176477
So, what can I suggest you? Replace the TMemo component with a TRichEdit as Mike said above. To make the change easy to implement, delete the Memo, place TRichEdit and name it as your memo name was (Memo1 for example). Change Richedit properties WordWrap to false and ScrollBars to ssBoth.

I've just added 10 000 lines 100 chars each this way successfully (almost 1MB). If the number of lines is enough to you, you can use your code with 10 000 lines limit.

Regards, Geo
0
 
LVL 4

Author Comment

by:delphi3
ID: 6177537
Thanks, Geo,
I have tried a bunch of things in an attempt to work around the problem. I finally settled
on the combination of StringList and now adding TRichEdit replacing TMemo, it expands the upper limit
by a factor of 10.

while RichEdit1.Lines.Count > 5000 do
                      RichEdit1.Lines.Delete(0);

Actually I still do not know how to  incorporate these deleted lines into the string list, that is using  the richedit being read,
 but thankfully I'll not get to the 5000 limit so soon


Thanks again for your research  and help

Delphi3
0
 
LVL 6

Expert Comment

by:edey
ID: 6177560
Hmmm...

Well, I'm glad you got a solution. Cheers

GL
Mike
0
 
LVL 5

Expert Comment

by:knowlton
ID: 6177928
I don't see how to turn off notification for this question.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question