trichview.com

trichview.support.examples




Example: word count


Return to index


Author

Message

Sergey Tkachenko

Posted: 11/08/2004 22:31:44


You can use a class from

http://www.trichview.com/resources/spell/rvspell.zip.

You need a unit RVWordEnum.pas from there (other files are specific for some

spell checkers).


Create a class


TWordCounter = class(TRVWordEnumerator)

private

    FCounter: Integer;

protected

    function ProcessWord: Boolean; override;

public

   function GetWordCount(rve: TCustomRichViewEdit): Integer;

end;


function TWordCounter.ProcessWord: Boolean;

begin

  inc(FCounter);

  Result := True;

end;


function TWordCounter.GetWordCount(rve: TCustomRichViewEdit): Integer;

begin

  FCounter := 0;

  Run(rve, rvesFromStart);

  Result := FCounter;

end;


(this function treats word written with two different fonts as two words)


Call:


var wcnt: TWordCounter;


wcnt := TWordCounter.Create;

r := wcnt.GetWordCount(RichViewEdit1);

wcnt.Free;





Powered by ABC Amber Outlook Express Converter