strstr
The strstr function finds a substring inside a string. This function returns the position of the first instance of the specified substring within the specified string. If strstr does not find the specified substring in the string, it returns a value of -1. This function is zero-based.
Syntax
Use this syntax:
integer = strstr("string","substring");
where: integer = integer variable
string = string
substring = part of the string
Example 1
An example of this function follows:
integer d;
d = strstr("mississippi","is");
//Finds the first instance of the substring "is" inside the string
//"mississippi" and returns the position of that first substring.
// d = 1 because this function is zero-based
Example 2
An example of this function that enables a purchase order number to be processed differently depending on its format (for example, if the third position of the purchase order number is numeric do “X,” and otherwise do “Y”) follows:
integer position;
string [1] PONumChar2;
PONumChar2=mid(#PONumber, 2, 1);
position=strstr("0123456789", PONumChar2);
//This function finds a substring within the string, so if the second
//position of purchase order number not equal to -1 then it is numeric and “X”
//should be executed, otherwise the second position is not numeric and “Y”
//should be executed.