
To retrieve part of a string in X++ you can use substr() function.
This is the function definition
str subStr(str _text, int _position, int _number)
Parameters
Parameter | Description |
---|---|
_text | The original string. |
_position | The position in the original string where the part to retrieve begins. |
_number | A signed integer that indicates the direction and number of positions to retrieve from the original string. If a minus sign precedes _number, the system selects the substring backward from the specified position. |
Here are some examples on how to use it :
subStr("ABCDEFGHIJ",3,5); //Returns the string "CDEFG".
subStr("ABCDEFGHIJ",7,-4); //Returns the string "DEFG".
subStr("abcdef",2,99) //Returns the string "bcdef".
subStr("abcdef",2,3) //Returns the string "bcd".
subStr("abcdef",2,-3); //Returns the string "ab".