Solved

TMemo and TStringList limits

Posted on 2001-08-24
6
1,704 Views
Last Modified: 2012-08-14
I tried to load a HTML file into a TMemo and also into a TStringList.  The HTML file was 43kb.  When I loaded the fil into the TMemo, only about half the file was loaded and visible in the TMemo.  When I loaded the file into a TStringList via LoadFromFile() I again was missing a sizeable portion of the file.  When I analyzed the Capacity and Count properties after TStringList.LoadFromFile I had a Capacity of 288 and a Count of 200.  And yet approx. 30% of the file was missing from the StringList.

Can anyone explain why this happens?
0
Comment
Question by:Monroe406
[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
6 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 6424007
Did you write to the Capacity property at all?
0
 

Author Comment

by:Monroe406
ID: 6424029
>> Did you write to the Capacity property at all?

Nope.  Prior to the LoadFromFile the Capacity and Count were at 0.  After the LoadFromFile they were 288 and 200 respectively.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6424040
This is probably something that would be easier to diagnose if I were to do it myself.  If you want, mail the HTML file to scrapdog@jvlnet.com, and I'll have a look.
0
Industry Leaders: 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 27

Expert Comment

by:kretzschmar
ID: 6424466
per default depending on the os the limit is 32K,

you can extend the limit of the memo up to 64K
using the EX_LIMITTEXT Message before loading

for larger files use a TRichedit, there the limit is default set to 64K,
but can extended up to 2GB

a sample follows

meikl ;-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 6424495
sorry i meant the message EM_EXLIMITTEXT

a sample with a trichedit

procedure TForm1.Button1Click(Sender: TObject);
begin
  Richedit1.Perform(EM_EXLIMITTEXT,0,$FFFFF);  //1 MB
  if Opendialog1.Execute then
    Richedit1.Lines.LoadFromFile(Opendialog1.FileName);
  RichEdit1.SelStart := Length(RichEdit1.Text);
  Richedit1.SetFocus;
end;

you must add the richedit-unit in the uses-clause
(there is this message-constant declared)

meikl
0
 
LVL 6

Expert Comment

by:edey
ID: 6425056
meikl beat me to it, so I'll have to sugest another alternative. Try this snippet in a project with a TWebBrowser, a TEdit & a TButton:

procedure TForm1.Button1Click(Sender: TObject);
var
   doc : variant;
begin
     webBrowser1.navigate(edit1.text);
     while webBrowser1.Busy do
           application.ProcessMessages;
     doc := webBrowser1.Document;
     doc.body.innerText := doc.body.innerHTML;
end;

GL
Mike
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…

752 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