Link to home
Start Free TrialLog in
Avatar of PiersBull
PiersBull

asked on

Word Count Function

Hi,
     I need to get / write a word counting function for a TMemo object. Anyone got any code or ideas?
Cheers.
ASKER CERTIFIED SOLUTION
Avatar of d003303
d003303

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PiersBull
PiersBull

ASKER

Hi amigo,
   I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.
oops, a little typo. replace the line
if (Buffer[Index] = #32) and (Buffer[Index + 1] <> #32)
with
if (TextBuf[Index] = #32) and (TextBuf[Index + 1] <> #32)

Slash/d003303
Hi again,

    Maybe I'm being thick, but how do I output the result in a messagebox? I've tried doing an IntToStr(WordCount), but the MessageBox command gives me a type mismatch. How do I output the result?
Points upa bit.
Cheers.

Application.MessageBox uses PChar strings. Declare a buffer string and typecast. e.g.
var MsgStr : string
begin
  MsgStr := Format('I have found %s words in this text', [WordCount]);
  Application.MessageBox(PChar(MsgStr), 'Note', mb_ok);
end;

Slash/d003303
Thanx

Hi amigo,
    I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.

Hi amigo,
    I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.

Hi amigo,
   I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.