Solved

How many strings can a memo hold?

Posted on 2001-06-07
9
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 5

Expert Comment

by:Tom 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:Tom Knowlton
ID: 6177928
I don't see how to turn off notification for this question.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

732 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