CRE Programmer's Guide
String and Memory Block Functions
Common Run-Time Environment (CRE) Programmer’s Guide—528146-004
8-32
Substring_Search
Substring_Search
The Substring_Search function determines whether one string is a substring of another
string. This function is not available in the native CRE library.
substr
is a pointer to the substring to scan for in str.
substr_len
is the length of substr in bytes.
str
is a pointer to the string to scan.
str_len
is the length of str in bytes.
Return Value
Substring_Search returns the position within str at which substr begins, or zero if
substr is not found within str. Note that the first character in str is at position one.
Considerations
The ends of the strings str and substr are determined by str_len and
substr_len, respectively. A zero (null) byte has no special meaning in this function.
Example
INT count;
STRING .s[0:28] := ["HP Computers Incorporated"];
STRING .subs[0:8] := ["Computers"];
! count gets 8
count := RTL_Substring_Search_(subs, 9, s, 29);
INT PROC RTL_Substring_Search_( substr, substr_len
str, str_len );
STRING .EXT substr; ! in
INT substr_len; ! in
STRING .EXT str; ! in
INT str_len; ! in TNS only