How do I export a text file with line breaks?

0 favourites
  • 8 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi there!

    I a have button that invokes a download from a string and save it as text file. Everything works fine except that the generated .txt file doesn't have line breaks.

    Instead of this:

    1- Player 1: 800 pts

    2- Player 2: 740 pts

    3- Player 3: 630 pts

    I get this:

    1- Player 1: 800 pts2- Player 2: 740 pts3- Player 3: 630 pts

    I've already tried using the newline expression inside my string and I've also tried "\n", "\r\n", and "\\n", but none of these have worked.

    Any idea?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How are you using the newline expression? Note that it shouldn't go inside the quotation marks, but should be concatenated with your strings, i.e.

    right -> "line 1" & newline & "line 2",

    wrong -> "line 1 newline line 2"

  • Notepad ignoring linebreaks...




  • Hi, guys!

    Thanks a lot for the answers.

    linkman2004: Yeah, I'm putting it outside the quotes.

    korbaach: I tried Notepad++ but it also ignored the line breaks. Anyway, the final users are not computer geeks, so they probably won't try alternative text editors.

    The solution that worked for me was to export as HTML and now I'm able to do all kind of formatting. \o/

  • something like this?

  • Like this! The idea is that you can set up a full HTML document through a string variable.

    I'm not an expert in HTML, so I grabbed Dreamweaver, created a simple table for the rank and copied its code.

    Inside of Construct 2, I divided the process in 3 parts:

    1 - The main part of the document (title, font, background color, and so on), before the loop.

    2 - Inside the loop, the rows that are appended for each iteration.

    3 - The end of the document's code definition, after the loop.

    Here is the .capx:

    Please, don't mind the HTML formatting. :p

  • Notepad ignoring linebreaks... Notepad++ Brackets Atom


    could you pls explain how do you save your data in a notepad file.i need this in my app.

  • Hi there, this is a working solution:

    1. create a variable named new_line

    2. set new_line to Browser.ExecJS("""\r\n""")

    3. before invoke download replace(yourtext, newline, new_line)

    happy coding

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)