Re: Line too long ???



alanglloyd@xxxxxxx wrote:

Its difficult to prevent when you're adding strings from another
source with different linebreak standards. Perhaps you should write a
small app to select a file with a TOpenDialog and which passes the
filepthname to a procedure like ...

procedure CorrectLineBreaks(FPN : string);
var
SL : TStringList;
Str : string;
begin
SL := TStringList.Create;
try
SL.LoadFromFile(FPN);
(*
Str := SL.Text;
AdjustLineBreaks(Str);
SL.Text := Str;
*)
SL.SaveToFile(FPN);
finally
SL.Free;
end;
end;

AdjustLineBreaks() and loading/saving to a stringlist should sort it
out for you.

A TStringList doesn't store linebreaks, and splits the lines correctly on LoadFromFile, so it's sufficient to LoadFromFile followed by SaveToFile. Reading SL.Text will insert the defined linebreaks, so AdjustLineBreaks has nothing to do at all.

DoDi
.



Relevant Pages

  • Re: [PHP] LOL, preg_match still not working.
    ... Addendum: I encountered a problem when the string contains linebreaks. ... adding \n\r into the brackets fixes your problem. ...
    (php.general)
  • Re: Breaking up text keep existing linebreaks
    ... The existing linebreaks need to be preserved. ... Optionally there is a maximum length for the returned string. ... Private Declare Function SendMessage Lib "user32" _ ... Dim nLines As Long, usedLines As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: TED and 30 Columns
    ... was kind enough to convert from the HP48 series. ... if you put in a 100-character string with no linebreaks, ... Strings were generally never "wrapped" even in viewers, ...
    (comp.sys.hp48)
  • Re: question on regular expressions
    ... > (no linebreaks) look like this: ... > my regular expression abilities are dismal. ... This works for the example string you gave: ...
    (comp.lang.python)