HP 3000 Manuals

func strpos [ System Debug Reference Manual ] MPE/iX 5.0 Documentation


System Debug Reference Manual

func strpos 

String position.  Returns the index of the first occurrence of one string
in another.

Syntax 

     strpos (source searchstring [position])

If searchstring is not found in source then zero (0) is returned.

Formal Declaration 

     strpos:u32 (source:str searchstring:str [position:u32=1])

Parameters 

 source          The string in which searchstring is to be found.

 searchstring    The string to be found in source.  It may be either a
                 single- or double-quoted string literal, or a
                 back-quoted regular expression.

 position        The character position in source where the search is to
                 begin.  If this parameter is not specified, the search
                 starts at the first character.  If this value is greater
                 than the size of the source string, a zero result is
                 returned.

Examples 

     $nmdebug > var source "Oh where oh where has my little dog gone" 
     $nmdebug > var searchstring "where" 
     $nmdebug > var first = strpos(source, searchstring) 
     $nmdebug > wl first 
     $4

Look for the string "where" in the source string and print the position
where it was found.

     $nmdebug > first = first + strlen(searchstring) 
     $nmdebug > var second = strpos(source, searchstring, first) 
     $nmdebug > wl second 
     $d

Look for the next occurrence of "where" in the source string and print
the position where it was found.

     $nmdebug > second = second + strlen(searchstring) 
     $nmdebug > var third = strpos(source, searchstring, second) 
     $nmdebug > wl third 
     #0

Look for another occurrence of "where" in the source string.  Since the
search string is not found, the value of zero (0) is returned.

Limitations, Restrictions 

none



MPE/iX 5.0 Documentation