Solved

LineBreak Code

Posted on 1999-01-12
8
248 Views
Last Modified: 2010-04-06
Hi,
how is the LineBreak Code in the TMemo Component ?
It seems so if #13 isn't enough. I've written a
replace function. Now I want to remove all Line Breaks
from the Memo1.Text.
0
Comment
Question by:ItsMe
8 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 0 total points
ID: 1356143
Hi itsyou,

Thought it was #13#10.

Hope this helps
:O)
0
 
LVL 5

Expert Comment

by:heathprovost
ID: 1356144
The actual line break can be #13, #10, #13#10, or #10#13 depending on the file type.  The presence of either or both of the characters will cause a line break.  You have to remove all accurances of either character.

Heath
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1356145
for i := 1 to Length(Memo.Text) do
  if (Memo.Text[i] = #13) or (Memo.Text[i] = #10) then
    Memo.Text[i] := #8;

Do you think #8 would delete it?

-Viktor
--Ivano
0
Independent Software Vendors: 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 3

Expert Comment

by:philipleighs
ID: 1356146
or like this:

var s: string;
begin
s := Memo.Text;
while Pos(#13#10, s) > 0 do
  begin
    Delete(s, Pos(#13#10, s), 2);
  end;
Memo.Text := s;


0
 
LVL 10

Expert Comment

by:viktornet
ID: 1356147
philipleighs, as heath proposed there might be cases when #13, #10, #10#13, or #13#10 are present so you need to know which one to use... the best way is to check for all the cases...
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1356148
I'm not so sure about your assertion vik and heath.
I have a file where each line is separated by #10 only.

In code I go:

var s: string;
begin
  Memo1.Lines.LoadFromFile('the file');
  s := Memo1.Text;

Looking at s in the debugger I notice that each #10 has been replaced by a #13#10 pair.

I have not tried the other combinations of #13 and #10 above, but I'm pretty sure that you'll see the same auto-conversion going on.

Cheers,
Phil.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1356149
well if you do this,,,

Memo1.Text := 'Whatever' + #10#13 + 'Whatever2';

then you'll see that there is a new line also and oyu cannot be sure which way it is represented.....
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1356150
Maybe you should try out your suggestion. It would appear that you *don't* get a linebreak, instead you see two vertical bars (the ones that represent control chars) between whatever and whatever2 on the same line.

This just reaffirms my standing that the only possible line break in memo.text is #13#10.

Regards
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi inherited method 6 80
Graphics32 under Delphi 10.1 Berlin 2 128
how can i delete one control based on its tagstring ? 6 38
Firemonkey Queue list 1 32
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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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