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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

Insert line break in x++

(0) ShareShare
ReportReport
Posted on by 282

Hi all

Running AX 2012 R3 CU9

Looking at an X++ method which I have that exports bill of exchange info to a text file at the moment. Basically it builds up a long string, and then exports that to the file.

eg:

outputTxt += strRFix(this.zipCode(), #ZipCode, '0');

.... (insert more here)

file.write(outputTxt);

However at a certain point, we have a business requirement to insert a carriage return on the line. I can't work out how to hardcode that. Is there a method which the X++ compiler will understand as Chr(13) or equivalent?

Thanks very much for your help in advance

Luke

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    48,805 User Group Leader on at
    RE: Insert line break in x++

    Hi Lukbel,

    In AX char2Num converts chars and gives you back the ASCI number. It will be great if you can be more transparent in providing your requirement. For line break \n is used in most of languages, same follows the x++

  • lukbel Profile Picture
    282 on at
    RE: Insert line break in x++

    Hi Sohaib,

    Basically what I would like to do is say, if I am hardcoding some text:

    outputTxt += "InsertTestCodeHere\nAndTheLineBreakShouldGoThere"

    But I was under the impression that the compiler would take that literally and insert the characters "\n"

    How can I tell it "put a carriage return here in the string"

  • Verified answer
    Sohaib Cheema Profile Picture
    48,805 User Group Leader on at
    RE: Insert line break in x++

    No I don't think so

    single \n will put new line. double backslash \\n will give you back \n in text. try following example in a job and you would know what I mean.

    str     myTestString;    
        myTestString += "InsertTestCodeHere\nAndTheLineBreakShouldGoThere";
        Box::info(myTestString);
        myTestString = '';
        myTestString += "InsertTestCodeHere\\n"+"AndTheLineBreakShouldGoThere";
        Box::info(myTestString);


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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans