trichview.com

trichview.support




Re: Extract Text by Pragraph and Line


Return to index


Author

Message

Sergey Tkachenko

Posted: 06/01/2002 18:29:58


Hi,


The function below returns text from the ParagraphIndex-th paragraph (first

paragraph has index = 0):


function GetTextFromParagraph(rv: TCustomRichView; ParagraphIndex: Integer):

String;

var i,j: Integer;

begin

  Result := '';

  for i := 0 to rv.ItemCount-1 do begin

    if rv.IsParaStart(i) then

      dec(ParagraphIndex);

    if ParagraphIndex<0 then begin

      for j := i to rv.ItemCount-1 do begin

        if (j>i) then begin

          if rv.IsParaStart(j) then

            break;

          if rv.IsFromNewLine(j) then

            Result := Result+#13;

        end;

        if rv.GetItemStyle(j)>=0 then

          Result := Result + rv.GetItemText(j)

      end;

      break;

    end;

  end;

end;


Note: paragraph can have line breaks inside (user can make them by pressing

Shift+Enter).

This function does not count these line breaks as paragraph starts, but adds

#13 characters at their place.


Paragraphs themselves are lines ended with carriage return (when user

pressed Enter (without Shift), she/he makes a new paragraph).



> Hi,

>

>  Is it possible to exttract the text from specific paragraphs. For example

> if I would like to extract the text from each pragraph to write it to

> seperate text files. Or if I would like to extract the text from paragraph

> 4... and write it to a file. (Without selecting the paragraph with mouse

or

> keyboard).

>

> Is it also possible to extract each line seperatly. (Line = string ended

> with a carriage return) ? (Also without selecting the line with mouse or

> keyboard).

>

> Thanks.






Powered by ABC Amber Outlook Express Converter