The strLib.indexOf() system function returns an index into a string of characters; the index indicates where a specified pattern begins.
strLib.indexOf(
source STRING | UNICODE | CHAR | DBCHAR | MBCHAR inOut,
pattern STRING | UNICODE | CHAR | DBCHAR | MBCHAR in
[, skipCount INT in] )
returns (result INT)
The following example locates the first two occurrences of a semicolon in the source string:
source STRING = "STRING; CHAR; DBCHAR; MBCHAR; or UNICODE.";
pattern STRING = "; "
result = strLib.indexOf(source, pattern);
// result is 7
result = strLib.indexOf(source, pattern, 10);
// result is 13
The following example locates all occurrences of blanks in the source string:
function indexOfExample()
text string = "A BC DEF GHIJ" ;
pIndex int = indexOf(text, " ", 0);
while(pIndex != 0);
writeStdOut("Blank index = " + pIndex);
pIndex = indexOf(text, " ", pIndex);
end
end
Blank index = 2
Blank index = 5
Blank index = 9