#include "x3_inc_string"
int GetWordCount(string sString)
{
int nCount;
string sWord = StringParse(sString);
while (sWord != "")
{
nCount++;
sString = StringRemoveParsed(sString, sWord);
sWord = StringParse(sString);
}
return nCount;
}
This is a pretty naive function. It won't work correctly for thing like "This.Is.A.Test" (the words are not separated by spaces) or "this is a . test" (since the punctuation is being caught as a word. Still, it's good for simple use cases where proper punctuation is used.