string.countWords

Syntax string.countWords (string)

Params string is the string in which you wish to determine the number of words.

Action Counts the number of words in string.

Returns Number indicating how many words are in string, with a word being defined based on the current value of wordChar.

Examples string.countWords ("Programmers drink lots of coffee.")

   » 5

string.countWords ("Frontier scripters have more fun.")

   » 5

In this example, extra spaces after "have" don't count; they are still one delimiter.

string.countWords ("New-York Mets")

   » 2

If the blank is still the word delimiter, the hyphen doesn't count. If the hyphen is now the word delimiter, there are still two words!

string.setWordChar(":");
string.countWords ("Hard Disk:System Folder:System")

   » 3

In this example ":" is set as the wordChar. Colons are separators, so spaces don't count as word delimiters.

Notes wordChar is by default a space. It is a Frontier variable you can control.

See Also string.getWordChar

string.setWordChar

string.nthWord

string.countFields

Discuss