How to add a new line when #13

General TRichView support forum. Please post your questions here
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

How to add a new line when #13

Post by pawnflakes »

Hi

I have a Database with memo fields which stores all my text. When a user requests a record I update TRichview from the DB (RichView.Add(Table.FieldByName('KeysCaptured').AsString,8);. Some of my text contains #13 characters. How can I add a blank line when TRichview encounters a #13.

Thank You
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Use AddTextNL instead of Add.
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post by pawnflakes »

Hi Sergey

I think you misunderstood me..

If my database field contains the following text:

This #13 is #13 a #13 test

I would like the text to be displayed like this when I load TRichView with the text:

This
is
a
test
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

RichView.AddTextNL(Table.FieldByName('KeysCaptured').AsString, 0, 0, 0);
Add and AddNL do not support line breaks, but AddTextNL does.
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post by pawnflakes »

Hi Sergey

I know that Addnl adds a new line but there is still a misunderstanding..

I allready have the text - the text is hard coded as follow:

This #13 is #13 a #13 test. When I load the text from my DB field, I load it in one go. The text is then displayed as "This #13 is #13 a #13 test" and not as:

This
is
a
test

I want to replace all the #13 characters with a blank line.. I hope that this better explain what I want.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I said, please do not use Add or AddNL, use AddTextNL instead, and you will get the results you need.
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post by pawnflakes »

Hi Sergey

In my previous post I meant AddTextNL and not AddNL. In any case, this does not work.

If we do your suggestion:

1 TButton and 1 TRichview on a form. The OnClick event for the button is:
RichView1.AddTextNL('This #13 is #13 a #13 test',8,0,0);
RichView1.Format;

The result in the TRichview is:
This #13 is #13 a #13 test

AND NOT

This
is
a
test
LS_M
Posts: 81
Joined: Thu Sep 15, 2005 5:17 pm

Post by LS_M »

Did you try AddTextNL('.....'+#10+#13+'....' ....

This one works for me InsertText('text1'+#10+#13+'text2');

- HL
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

pawnflakes: Your text string is incorrect, it does not have line break characters. The correct test is 'This '#13' is '#13' a '#13' test'.

LS_M: InsertText supports #13#10 too. But it is used to insert text in the caret position as an editing operation, while AddTextNL is used to generate new document.
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post by pawnflakes »

Thanks Sergey and LS_M.

It works but it still doesn't solve my problem. I'm writing a keylogger application that captures all keys entered. When a user presses enter, a #13#10 code is added to the text. The text gets saved to a Database and then transferred to trichview on request. Is there no event for TRichview to replace all the #13#10 codes with a linebreak when the text gets loaded from the DB? I can't add the text line by line from the DB to trichview.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As I understand, your problem happens because you do not add line break characters to db.
Instead, you add 6 characters: '#', '1', '3', '#', '1', '0'.

Your problem will be solved if you add #13#10 instead.
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post by pawnflakes »

Hi Sergey

When a user presses enter a #13#10 gets inserted. The problem is that the rest of the strings are not preceeded and ended with a colon. It seems that I will manually have to add colons.

All I wanted to know is whether it is possible to replace all the #13#10 charcters with the relevant linebreaks when I load the text to TRichview e.g.
an OnLoad event in TRichview that replaces any combination of characters with whatever I decide. It seems that it is not possible - don't worry, i will make another plan to solve this problem.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Of course it is possible to replace characters before adding to trichview, but if you really insert #13#10 characters, no replacing is needed, just call

Code: Select all

rv.Clear;
rv.AddTextNL(text_from_db, 0, 0, 0);
rv.Format;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I you can send me a sample application reproducing the problem you have, please send it to richviewgmailcom.
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Post by pawnflakes »

There is no need to send a sample application:

Let's assume we have a memo with the text: This #13#10 is #13#10 a #13#10 test //This is the text that I obtained from my keylogger - notice, the text is without colons because the keylogger doesn't know where to add colons..

Now, if I have a TRichView and button with an onClick event of the following:

rv.AddTextNL(memo1.text, 0, 0, 0);
rv.Format;

The text in TRichView is the same as in the memo without line breaks because there are no colons in the string. What I want to achieve is for TRichView to replace all #13#10 characters with a linebreak when i load the text from the memo to TRichview.

I hope you understand now what my problem is..
Post Reply