Example:
GTM> WRITE $FIND("HIFI","I") 3 GTM>
This example uses $FIND() to WRITE the position of the first occurrence of the character "I." The return of 3 gives the position after the "found" substring.
Example:
GTM> WRITE $FIND("HIFI","I",3) 5 GTM>
This example uses $FIND() to WRITE the position of the next occurrence of the character "I" starting in character position three.
Example:
GTM> SET t=1 FOR SET t=$FIND("BANANA","AN",t) Q:'t W !,t 4 6 GTM>
This example uses a loop with $FIND() to locate all occurrences of "AN" in "BANANA". The $FIND() returns 4 and 6 giving the positions after the two occurrences of "AN".
Example:
GTM> SET str="MUMPS databases are hierarchical" GTM>WRITE $FIND(str," ") 7 GTM>WRITE $FIND(str,"Z") 0 GTM>WRITE $FIND(str,"d",1) 8 GTM>WRITE $FIND(str,"d",10) 0
The above example searches a string for a sub string, and returns an integer value which corresponds to the next character position after locating the sub string.