trichview.com

trichview.support




Re: Questions about words & paragraph & picture ?


Return to index


Author

Message

Yernar FoxTail

Posted: 11/18/2002 9:29:59


And finally to get the number of words:


function GetWordCount(RVData: TCustomRVData): Integer;

var

  i, r, c: Integer;

  table: TRVTableItemInfo;

  s: String;


  function Seps(As_Arg: Char): Boolean;

  begin

    Seps := As_Arg in

      [#0..#$1F, ' ', '.', ',', '?', ':', ';', '(', ')', '/', '\'];

  end;

  function WordCount(CText: string): Integer;

  var

    Ix: Word;

    Work_Count: Integer;

  begin

    Work_Count := 0;

    Ix := 1;

    while Ix <= Length(CText) do

    begin

      while (Ix <= Length(CText)) and (Seps(CText[Ix])) do

        Inc(Ix);

      if Ix <= Length(CText) then

      begin

        Inc(Work_Count);

        while (Ix <= Length(CText)) and (not Seps(CText[Ix])) do

          Inc(Ix);

      end;

    end;

    WordCount := Work_Count;

  end;

begin

  Result := 0;

  for i := 0 to RVData.Items.Count - 1 do

    if RVData.GetItemStyle(i) >= 0 then begin

      s := RVData.Items[i];

      Result := Result + WordCount(s);

    end

    else if RVData.GetItemStyle(i) = rvsTable then begin

      table := TRVTableItemInfo(RVData.GetItem(i));

      for r := 0 to table.Rows.Count - 1 do

        for c := 0 to table.Rows[r].Count - 1 do

          if table.Cells[r, c] <> nil then

            Inc(Result, GetWordCount(table.Cells[r, c].GetRVData));

    end;

end;



"david" <[email protected]> wrote:

>How can i get the number of words and paragraph and number of picture in

>RichViewEdit ?

>Thank for your answer...





Powered by ABC Amber Outlook Express Converter