Page 3 of 3

Posted: Thu Jul 28, 2005 3:10 pm
by Trond
Number of words

Code: Select all

numofwords.l = CountString(Trim("sentence to count the number of words in"), " ")+1
By the way, in traditional basic, the CountString() function is called Tally.
ebs wrote:Fred,

Would you consider adding something like the VB "Split" function? It fills an array with string fields separated by a specified delimiter. It's very handy for parsing words in a sentence and comma or tab delimited files.

Regards,
Eric
It's very handy, and that's why it's added already. It's called Field.

Posted: Thu Jul 28, 2005 3:18 pm
by PB&J Lover
Trond wrote:numofwords.l = CountString(Trim("sentence to count the number of words in"), " ")+1
That's very good. I'll use it, but it doesn't work if there are extra spaces in the line (which I often encounter). So I'll still remove them.

Here's my final procedure:

Code: Select all

Procedure.l WordCount(Text$)
ProcedureReturn CountString(Trim(RemoveExtraSpaces(Text$))," ") + 1
EndProcedure
Thanks.