Link to home
Start Free TrialLog in
Avatar of AllenC
AllenC

asked on

TMemo > 32k?

I'm currently using Delphi v1 for a compiler IDE. But, when ever I try to open a file biggers than 32k, I receive the error "Text greater than 32k". Is there a way to overcome the TMemo and/or Win 3.x edit control limit?

Thanks
http://tcp.home.ml.org/
Avatar of ZifNab
ZifNab

Look at these components :

 http://carbohyd.ras.ru/torry/vcl/edits/jmpmemo.zip
  (can view text over 1MB, so it says)

 and offcourse there is also a shareware version :

 http://carbohyd.ras.ru/torry/vcl/edits/plusmemo.zip

Have fun,
c.u. ZifNab;
Avatar of AllenC

ASKER

I tried to access the server many times, but failed. (not even with a proxy server)

http://tcp.home.ml.org/
I'll try to send them to you.

If you receive this file then reject me if not then :

http://carbohyd.siobc.ras.ru/torry/vcl/edits/jmpmemo.zip


Avatar of AllenC

ASKER

I've tried the component, but it can only show and does not allow any inputs. (read-only)

Correct me if I'm wrong :)
Assume that you have a form with a memo and two buttons. The first button is to open and load a file. The second button is to show more porttions of the file (32k at a time). {You can replace the second button with a proper PageDown handler function}. Use the blockread function to read a block of data -32k at a time, and then place it in the memo. When the user clicks the "ShowMore" button, the next 32k of data is shown. When you call the blockread function, the last parameter actually tells you how much has been read. If it is lesser than 32k, then add a null (0) at the end so that the memo component will not take data beyond that. Also note that we have defined c_data as an array of characters pointing exactly to the same address of the data array. This is a working example which we are using for files greater than 15 MB in size - but we have adapted it to different situations. You will have to fine tune it to your environment. In D3, we have derived a component out of TMemo to make it faster for huge files though it supports unlimited sizes. In D3 the component becomes very slow when you load a file more than 1MB in size.

var
  Form1: TForm1;
  data:array[1..32767] of byte;
  c_data:array[1..32767] of char absolute data;
  {c_data and data are both pointing to the same location}
  f:file; {File which is going to be loaded in the memo}
  i,max:integer;

implementation

{$R *.DFM}

procedure TForm1.ButtonShowMoreClick(Sender: TObject);
begin
     BlockRead(f,data,32767,max);
     if max<32767 then data[max+1] := 0;
     Memo.Text := c_data;
end;

procedure TForm1.ButtonLoadClick(Sender: TObject);
begin
     AssignFile(f,'test');
     Reset(f,1);
     ButtonShowMoreClick(Self); {To load the first 32 k}
end;

Avatar of AllenC

ASKER

It looks an alternative to me, but the point is, my program is an IDE for FPK-Pascal. If I put down the "show more" button, it'll make the program very difficult to use and requires lots of changes to the program code itself.
Of course, you should not put a "Show More" button, you should attach it to the ScrollBar and KeyPress event of the Memo - check whether you are at the end of the memo and then load the next section. As I said earlier, this is the way we are forced to handle very huge files, loading the whole file takes too much time on NT though the TMemo component in D3 supports very huge files.
ASKER CERTIFIED SOLUTION
Avatar of altena
altena

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial