Solved

How many strings can a memo hold?

Posted on 2001-06-07
9
188 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now