Monday, April 6, 2020

Left Right String padding in X++

We will see how to add the character on the left side or the right side of string.
it is very simple for this we will use two functions.

For right side padding we use strLfix(str _str, int _lenght [, char _char])
For Left side padding we use strRfix(str _str, int _lenght [, char _char])


     str text = "Score";

    str leftPadding,rightpadding;
    // for right side padding we use strLFix function
    leftPadding = strLFix(text,strLen(text)+1,'s');
    info(strFmt("Right side padding result - %1",leftPadding));

     
    // for left side padding we use strRFix function
    rightpadding = strRFix(text,strLen(text)+1,'s');
     info(strFmt("Left side padding result- %1",rightpadding));


No comments:

Post a Comment

Please do not add any spam link in the comment box.