Finding the occurrence of string within another string through X++

Written By: Fatima Zafar

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(“Not Found”);




About the author

Fatima Zafar is an Associate Software Engineer in the Dynamics Team at Systems Limited. She is extremely passionate about her work and loves to explore development platforms and tools. As a technology oriented person, she has under her belt a wide range of experiences including technical writing, tutorial development and blogging for technology and has dabbled (significantly well) with X++, .NET and MySQL. Currently working as a Microsoft Dynamics AX developer, she aims to explore as many areas of Dynamics as she can. Other than AX, her passions include graphic designing and she would like to work more on that front as well.

Leave a Comment

Name (required)
Email (required)
Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>