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)
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
    49,677 Super User 2026 Season 1 on at

    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

    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
    49,677 Super User 2026 Season 1 on at

    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

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