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.
I need to get / write a word counting function for a TMemo object. Anyone got any code or ideas?
Cheers.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
if (Buffer[Index] = #32) and (Buffer[Index + 1] <> #32)
with
if (TextBuf[Index] = #32) and (TextBuf[Index + 1] <> #32)
Slash/d003303
ASKER
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.
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(PCh ar(MsgStr) , 'Note', mb_ok);
end;
Slash/d003303
var MsgStr : string
begin
MsgStr := Format('I have found %s words in this text', [WordCount]);
Application.MessageBox(PCh
end;
Slash/d003303
ASKER
Thanx
ASKER
Hi amigo,
I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.
I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.
ASKER
Hi amigo,
I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.
I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.
ASKER
Hi amigo,
I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.
I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.
ASKER
I've tried the code, but it gives me an unknown identifier at Buffer[index]. Any ideas?
Cheers.