Author: Jonas Bilinkevicius How to count words in a TRichEdit Answer: 1 2 function GetWord: boolean; 3 var 4 s: string; {presume no word > 255 chars} 5 c: char; 6 begin 7 result := false; 8 s := ' '; 9 while not EOF(f) do 10 begin 11 read(f, c); 12 if not (c in ['a'..'z', 'A'..'Z' {,... etc.}]) then 13 break; 14 s := s + c; 15 end; 16 result := (s <> ' '); 17 end; 18 19 procedure GetWordCount(TextFile: string); 20 begin 21 Count := 0; 22 assignfile(f, TextFile); 23 reset(f); 24 while not EOF(f) do 25 if GetWord then 26 inc(Count); 27 closefile(f); 28 end;