NUMTOKEN() Determines the number of tokens in a string ------------------------------------------------------------------------------ Syntax NUMTOKEN(<cString>,[<cDelimiter>],[<nSkipWidth>]) --> nNumber Arguments <cString> Designates the string that is passed. <cDelimiter> Designates the delimiter list used by the passer. <nSkipWidth> Designates after what number of delimiter characters or sequences to count a token. This is helpful for counting empty tokens. The default value indicates that empty tokens are not taken into account. Returns The number of tokens contained in the <cString> is returned. Description Use NUMTOKEN() to determine how many words (or tokens) are contained in the character string. The function uses the following list of delimiters as a standard: CHR 32, 0, 9, 10, 13, 26, 32, 138, 141 and the characters ,.;:!?/\<<>>()^#&%+-* The list can be replaced by your own list of delimiters, <cDelimiter>. Here are some examples of useful delimiters: Table 4-3: Recommended Delimiter Sequences ------------------------------------------------------------------------ Description <cDelimiter> ------------------------------------------------------------------------ Pages CHR(12)(Form Feed) Sentences ".!?" File Names ":\." Numerical strings ",." Date strings "/." Time strings ":." ------------------------------------------------------------------------ The skip value designates the number of characters after which a token is counted again. This also allows empty tokens, like blanks within a string, to be counted. Examples . A character string is searched using the standard delimiter list: ? NUMTOKEN("Good Morning!") // Result: 2 . Your own list of delimiters can be specified for particular reasons. Since the delimiter list for the following example only contains the characters ".!?", the result is 3. ? NUMTOKEN("Yes! That's it. Maybe not?", ".!?") . This example shows how to count empty tokens. Parameters separated by commas are counted, but some of the parameters are skipped. A token is counted after at least one delimiter (comma): String := "one,two,,four" ? NUMTOKEN(String, ", ", 1) // Result: 4
See Also: TOKEN() ATTOKEN() TOKENUPPER() TOKENLOWER()