AX / D365FO – Finding the occurrence of string within another string through X++

Searches a text string for an occurrence of another string.

int strScan(str _text1, str _text2, int _position, int _number)

The comparisons aren’t case-sensitive. Values for the _position parameter that are less than 1 are treated as 1. The direction of the scan is controlled by the sign that is specified in the _number parameter. A positive sign indicates that each successive comparison will start one position closer to the end of the string. A negative sign indicates that each comparison will start one position closer to the start of the string.

strScan("ABCDEFGHIJ","DEF",1,10); //Returns the value 4.

strScan ("ABCDEFGHIJ","CDE",10,-10); //Returns the value 3.

Leave a comment