Solved

How many strings can a memo hold?

Posted on 2001-06-07
9
191 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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