Finding the occurrence of string within another string through X++
29AUG
X++ offers a lot of string functions to be used on the strings. Here, we will be using the “strscan” function. The “strscan” searches for a string within another string
————————————————————————————————————-
The strscan function takes the following arguments
Strscan (str text, str characters, int position, int number);
Text: The target string
Characters: The string to be found
Position: The first position in the target string to perform the search
Number: Number of times search will be performed. Normally, it is the length of the original string. If a negative sign is used in this argument, the search operation is performed in the reverse order
————————————————————————————————————-
Below is the code to find any character in a string.
int position;
str targetstring = “ABCD”
position = strscan( targetstring, “CD”,3,strlen(targetstring);
if (position)
{
info(“Found”);
}
else
{
info(“Not Found”);
}
No comments:
Post a Comment