{ Coloca cada palavra de uma string em uma lista de strings,
   retornando quantas strings a lista possui. }
function SplitStr(S: string; const Delim: char; const List: TStrings;
  const AllowEmpty: Boolean = true): integer;
var
  i: integer;
begin
  Result := 0;
  List.Clear;
  if Assigned(List) then
  begin
    List.Delimiter := Delim;
    List.DelimitedText := S;
    if not AllowEmpty then
      for i := 0 to Count - 1 do
        while (List[i] = EmptyStr) and Boolean(List.Count) do
          List.Delete(i);
  end;
  Result := List.Count;
end;

{ Conta quantas palavras existem em uma string }
function CountWords(S: string): integer;
begin
  with TStringList.Create do
  try
    Delimiter := ' ';
    DelimitedText := S;
    Result := Count;
  finally
    Free
  end
end;


Sds.,

Rubem Rocha
Manaus, AM
_________________________________________________________________
Conheça o Windows Live Spaces, a rede de relacionamentos do Messenger!
http://www.amigosdomessenger.com.br/

Responder a