From: "Grega" Subject: Re: How many words ? Date: 21 Jan 2000 00:00:00 GMT Message-ID: <8690ka$i1s21@bornews.borland.com> References: <867hve$hip6@bornews.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Spin X-MSMail-Priority: Normal Reply-To: "Grega" Newsgroups: borland.public.delphi.objectpascal type TEnumWordsCallBack = function (AWord: String; StartPos: Cardinal): Boolean; TWordSeparators = set of Char; //************************************************************************** * // It finds words in string betwen two delimiters which are passed in WordSeparators. // CallBack is called for every found word //It is processing untill end of string or CallBack return false //************************************************************************** * function EnumWords(Text: String; WordSeparators: TWordSeparators; EnumFunc: TEnumWordsCallBack): Cardinal; var i, Len, Mark: Integer; CallBackResult: Boolean; AWord: String; begin //init variables i := 1; Len := Length(Text); Mark := 0; CallBackResult := true; Result := 0; //process word until CallBack function returns false //or end of text is reached while CallBackResult and (i <= Len) do begin //if word separator is reached, tha is end of the word if (Text[i] in WordSeparators) then begin //if Mark is greater than 0 then we have a word if Mark > 0 then begin //call CallBackFunction AWord := Copy(Text, Mark, i - Mark); Inc(Result); CallBackResult := EnumFunc(AWord, Mark); Mark := 0; end; end else begin //you are somewhere in the the word //if Mark is 0 then this is start of the next word if Mark = 0 then Mark := i; end; Inc(i); end; //last word if CallBackResult and (Mark > 0) then EnumFunc(Copy(Text, Mark, i - Mark + 1), Mark); end; Grega! Alejandro Castro je v sporočilu novic 867hve$hip6@bornews.borland.com napisal ... > Hi > > How can I know, on a easy way, the number of words on a Memo Field ? > > Is there a property for that or a thirdparty component that include it ? > > Thanks > > Alejandro