PrevPar after clearing paragraph

  • Why does this go into an infinate loop? I'm trying to set all paragraphs prior to a particular position to blank lines.

    while not (par = nil) do
    begin
    par.SetText('');
    par := par.PrevPar;
    end;

    It works if I insert a space, but not if I insert an empty string.

    Is there a better way to do this?

    • Offizieller Beitrag

    For me this code works fine:

    Code
    par := WPRichText1.ActiveParagraph;  while not (par = nil) do  begin    par.SetText('');    par := par.PrevPar;  end;  WPRichText1.ReformatAll(false, true);

    but you can also do it like this:

    Code
    par := WPRichText1.ActiveParagraph;
      while not (par = nil) do
      begin
        par.ClearText(false);
        par := par.PrevPar;
      end;
      WPRichText1.ReformatAll(false, true);
  • I have no idea what changed since I posted the question, but it's working now. I must have fixed something taking place just prior to that code.

    I must say that the more I code with version 5 the more I like it! So many elegant solutions for what I need to accomplish.