Occurs()
It might be better if this function were called "occurrences" because that's what it counts. OCCURS() returns the number of times one string is contained in another. For example, if you want to know how many times "iss" occurs in "Mississippi", OCCURS() is just what you need.Let's say (in spite of relational theory) you've stored a series of codes in a memo field, separated by spaces, and you want to know how many codes a given record has. Use OCCURS() to count the spaces, then add 1 to get the result.
Usage |
nReturnValue = OCCURS( cSearchFor, cInString ) |
Example |
* cInput is the input string * store the results in array aValues with one item per element nItems=OCCURS(",",cInput) DIMENSION aValues[nItems+1] FOR nCnt=1 TO nItems * find the first comma nCommaPos=AT(",",cInput) * grab the string before it aValues[nCnt]=LEFT(cInput,nCommaPos-1) * shorten the string IF nCommaPos<>LEN(cInput) cInput=SUBSTR(cInput,nCommaPos+1) ELSE cInput="" ENDIF ENDFOR * now take last item * check just in case there was a trailing comma IF EMPTY(cInput) DIMENSION aValues[nItems] ELSE aValues[nItems+1]=cInput ENDIF |
See Also |
$, At(), InList(), Left(), RAt(), Right(), SubStr(), Upper() |