getTokenCount()
The strLib.getTokenCount() system function returns the number of tokens in a source string.
Tokens are strings separated by delimiter characters.
For example, if you define the characters space (" ") and comma (",")
as delimiters, the string "CALL PROGRAM ARG1,ARG2,ARG3" separates
into five tokens: "CALL", "PROGRAM", "ARG1", "ARG2",
and "ARG3".
Syntax
strLib.getTokenCount(
source STRING in,
delimiters STRING in)
returns (result INT)
- source
- Input can be any variable or expression that is assignment compatible with the STRING type.
- delimiters
- A STRING containing one or more delimiter characters, with no characters separating one from the next.
- result
- An INT representing the number of tokens found in source. If no token is found, the function returns 0.
Example
In the following example, the space and comma characters separate four tokens:
commandLine STRING = "CALL PROG1 arg1,arg2";
delimiters STRING = " ," // space and comma delimiters
i INT;
i = StrLib.getTokenCount(commandLine, delimiters);
// i = 4
Compatibility considerations
| Platform | Issue |
|---|---|
| JavaScript™ generation | The function strLib.getTokenCount() is not supported. |