| INCLUDE | Index Level | INMAT |
| Syntax | INDEX( string.expression, substring.expression, num.expression ) |
| Category | BASIC |
| Type | Function |
| Description |
searches through a given "string.expression" for the occurrence of the character or substring specified by "substring.expression" and if found, returns the numeric position at which the nth occurence of the substring begins. Null strings are skipped.
The "num.expression" defines a particular occurrence to find, (nth occurrence). If the nth occurence of the specified substring is not found, "0" (zero) is returned. |
| Options | |
| See Also | statements & functions string.expression num.expression functions |
| Example |
d.position = index("abcdefg","d",1)
This returns the value, "4", to the variable "test", since the first occurrence of "d" is found in the fourth position of the string. on index("abcdefg",response,1) goto 10,20,30,40,50,60,70 This example exploits the fact that "index" returns a number indicating the position of the search character. For instance, if "response" is the letter "d", then it will goto statement label 40. loop input ans,1 until ans#'' and index('abc',ans,1) do repeat If "ans" is not null and is either an a, b, c, ab, or bc, the loop is terminated. Notice that the null condition must be tested separately since a null value for "ans" results in a "1" from the "index" function. |
| Warnings | Searching for a null in any string gives a result of one. |
| Compatibility | D3 7.0 AP R83 |
| INCLUDE | Index Level | INMAT |