Mirror

How to convert a word wrap in a TMemo to a CR/LF (Views: 100)


Problem/Question/Abstract:

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

Answer:

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;

<< Back to main page