Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TMemo : Convert wrap to CR/LF

163 views
Skip to first unread message

Daniel K

unread,
Sep 28, 2000, 3:00:00 AM9/28/00
to

Using a TMemo, is it possible to convert each wrap to a CR/LF, or even at a specific column (like 67 or 80)?

Thanks
Daniel

Joe Real

unread,
Sep 28, 2000, 3:00:00 AM9/28/00
to
Try loading a memo with long text per line and save it to file.

Memo1.Lines.LoadFromFile('FileWithLongLines.TXT');
Memo1.Lines.SaveToFile('WhatHappened.TXT');

then open the WhatHappened.TXT with NotePad and see for yourself.


"Daniel K" <Daniel....@Advalvas.be> wrote in message
news:39d2eccf$1_2@dnews...

Daniel K

unread,
Sep 28, 2000, 3:00:00 AM9/28/00
to

"Joe Real" <nge...@thegrid.net> wrote:
>Try loading a memo with long text per line and save it to file.
>
>Memo1.Lines.LoadFromFile('FileWithLongLines.TXT');
>Memo1.Lines.SaveToFile('WhatHappened.TXT');
>
>then open the WhatHappened.TXT with NotePad and see for yourself.
>
>
If one imports a text from another editor, the lines are wrapped,
indeed. But when saved to file and opened again, the format is
not 67 (or 80) chars per line. How do I force 67 (or 80)
chars per line? I need to put a CR/LF at each end of the line, but a simple for i:=0 to memo1.Lines.Count -1 do memo1.Lines[i] := memo1.Lines[i] + #13#10; does not work...

Daniel

Daniel

Thomas Nelvik

unread,
Sep 28, 2000, 3:00:00 AM9/28/00
to
Perhaps AdjustLineBreaks() function is useful for you.

Memo1.Lines.Text := AdjustLineBreaks(Memo1.Lines.Text);

Force length of line?
Isn't that up to the editor?

for I := 0 to Memo1.Lines.Count - 1 do
begin
if Length(Memo1.Lines[I] < 67) then
Memo1.Lines[I] := Memo1.Lines[I] + StringOfChar(' ', 67 -
Length(Memo1.Lines[I]));
end;

-ThomasN


Daniel K wrote:

dave charters

unread,
Sep 28, 2000, 3:00:00 AM9/28/00
to
How about this?

const limit = 67;
var S: String; i: Integer;
begin
S := Memo1.Text;
Memo1.Clear;
repeat
i := limit;
while S[i] <> ' ' do
Dec(i);
Memo1.Lines.Add(Trim(Copy(S, 1, i)));
Delete(S, 1, i);
until Length(S) = 0;
end;


Daniel K

unread,
Sep 28, 2000, 3:00:00 AM9/28/00
to

Dave, this does the trick! Thanks. Now why didn't I think of this before ;-)

Daniel


0 new messages