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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Reverse String in AX

(1) ShareShare
ReportReport
Posted on by 4,624

Hi All,

I am using below code for reverse string :

static void reverseString(Args _args)
{
str string = "My name is test";
str string3 = "";
List string1 = new List(Types::String) ;
int i ;

;
string1 = strSplit(string,string3);
for(i=string1.elements()-1;i>=0;i--)
{
string3 = string1.addEnd(i)+string3 ;
}

info(str2int(string3));
}

My output would be like : "test is name my" but code is not working as expected. 

Please suggest

*This post is locked for comments

I have the same question (0)
  • Basheer17 Profile Picture
    2,720 on at

    Correction: Didn't read the question completely.

    You can use strReverse instead.

  • Rohin Profile Picture
    4,624 on at

    Yes, i can use strReverse but it will give output like :  "tset si eman ym"

    but I want output like : "test is name my"

    so how to achieve  this in AX?

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    Try this:

    static void Job21(Args _args)

    {

       str string = "My name is test";

       str string3 = " ";

       str result;

       container con;

       ;

       con = str2con(string,string3);

       con = conReverse(con);

       result = con2Str(con,string3);

       info(result);

    }

  • Rohin Profile Picture
    4,624 on at

    Yes ,it works but i am looking the other way of work around means without using AX built in functions(like you used conReverse())  so can i achieve this without using functions?

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    I don't know hey you need it but you can just add a for loop instead of a built in function.

    static void Job21(Args _args)

    {

       str string = "My name is test";

       str string3 = " ";

       str result;

       container con;

       int i;

       ;

       con = str2con(string,string3);

       for( i = conLen(con); i > 0; i-- )

       {

           result += conPeek(con,i) + string3;

       }

       info(result);

    }

  • Verified answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    Although all you are asking for here, is a logic for reversing a string, which isn't directly related to AX.

    The above code will give you an extra space at the end, but I'm sure you can find a way to adjust that.

  • Rohin Profile Picture
    4,624 on at

    thanks Zain , it works

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    You're welcome. Please mark the answers with the code as verified. Thanks.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans