?
Solved

TRichEdit-problem

Posted on 1997-08-13
5
Medium Priority
?
297 Views
Last Modified: 2010-04-06
Hi.

Sorry, I dont have any more points. If you know a good answer to my question please notify my and i will by some points to give you!!!!! Thanx.

I have a TRichEdit (RichEdit1) that I load large files into. I want to examin if the format of these files are correct. I do that by running through the file line by line.
My problem is that...

var
  St1 : string;
begin
  St1 := RichEdit1.Lines[no];
...

...takes more and more time as no gets higher. I work with very large files and the time used on the formatchecking is just to long. I have tried to use the Text-property and some pointer-gym. istead (having a pointer pointing to the beginning of the next line and just create the string from the pointer) and that worked fine in the beginning, but the i got in some problems doing that (Very, very, very strange problems).
Now i want to know if any of you guys know how to work around my problem (Reading through all the lines of a large TRichEdit, without using alot of time)?
Anyone one know of a desant of TRichEdit that might have some functionality that I could use?

Thanx - Steff
0
Comment
Question by:steff
[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
  • 2
5 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1341312
TRichEdit (Delphi2) don't have TEXT property and lines is TStrings so works very fast. You can't made this faster.
p.s. You can buy some point's
0
 

Author Comment

by:steff
ID: 1341313
I have Delphi2 and I also have a Text-property to work with. I might have a older version of Delphi2????
If you know any way for me to get this fast TRichEdit I would realy like to know!

Thanx - Steff
0
 

Author Comment

by:steff
ID: 1341314
Adjusted points to 30
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 120 total points
ID: 1341315
Hi Stef.

Ok. When You send me example i just know what you need. TRich edit have'nt Text property but you can retrive the text with send message.


{ Here is stupid example but i think so this can help you }

....
{declaration's}
....

uses
  RichEdit, ....{other unit's}  ;

procedure AnyName;
var
  L: Integer;
  TextRange : TTextRange;
  i,k : integer;
  st : string;
begin
  TextRange.chrg.cpMin := 0;
  TextRange.chrg.cpMax := 10239;
  GetMem( TextRange.lpStrText, 10240 );
  L := SendMessage(RichEdit1.Handle, EM_GETTEXTRANGE, 0, Longint(@TextRange));
  for i:=1 to (l div 10) do
  begin
    st := '';
    for k:=1 to 10 do
      st := st + TextRange.lpStrText[10*(i-1)+k-1];
    Memo1.Lines.Add(st);
  end;
  FreeMem( TextRange.lpStrText, 10240 );
end;


TTextRange structure is defined in RichEdit.Pas unit and Win32.HLP describes more about TRichEdit control.

type
  TCharRange = record
    cpMin: Longint;         { number of first char to retrieve }
    cpMax: LongInt;        { number of last char to retrieve }
  end;

  TTextRange = record
    chrg: TCharRange;
    lpstrText: PChar;      { buffer where data will be copied }
  end;

Mirek
0
 

Author Comment

by:steff
ID: 1341316
OK! Thanx alot.

I will see what I can use your answer for. If I have a few more questions conserning the same matter I hope you will accept me sending you a e-mail about it.

Thanx again - Steff
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

801 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