web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to repeat String with x++

(0) ShareShare
ReportReport
Posted on by 916

Hi,

I'm looking for the equivalent of this function to repeat string: 

info(strRFix('Alex',10,'*')); //******Alex  => ok


i want somthing like : 

info(strRFix('Alex',15,'strRep')); // iget sssssssssssAlex but how to get : strRepStrReAlex

Any help ?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi Alex,

    There is no function out of the box to do what you asking, at least I'm not aware of. However, you can always write new one.

    Here is small example I built for you:

    str myMagicStrRep(str _source, str _strRep, int _number)
        {
            int sourceLength = strLen(_source);
            int strRepLength = strLen(_strRep);
            int repCount;
            
            if (_number < 1 || !strRepLength)
            {
                return '';
            }
            
            if (sourceLength > _number) 
            {
                return  subStr(_source, 1, _number);
            }
            
            repCount = (_number div strRepLength) + 1;
                    
            return subStr(strRep( _strRep, repCount), 1, _number - sourceLength) + _source;
        }
        
        info (myMagicStrRep('Alex','strRep', 15));


    It's not ideal and you definitely could improve it, but I think you will get an idea. 

  • Suggested answer
    Denis Macchinetti Profile Picture
    16,444 on at

    Hi Alex

    Another options is to use the .NET Framework CLR type.

    msdn.microsoft.com/.../cc584291.aspx

    Below an example that for sure can improve and become an Global Function :

       System.String       string, replaceChar;

       str                         finalString, fixedString = 'Alex';

       int                         stringLenght = 10;

       // Your version

       info(strRFix('Alex',stringLenght,'*'));

       //////////////////

       replaceChar = "X";

       string = New System.String(replaceChar.get_Chars(0), stringLenght);

       string = string.Replace(replaceChar, "*");

       finalString = string.ToString();

       finalString = subStr(finalString, 1, stringLenght - strLen(fixedString) ) + fixedString;

       Info (finalString);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans