How do I export a text file with line breaks?

Get help using Construct 2

Post » Wed Jun 01, 2016 5:22 pm

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?
B
8
S
1
Posts: 21
Reputation: 488

Post » Wed Jun 01, 2016 6:25 pm

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"
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Wed Jun 01, 2016 6:46 pm

Notepad ignoring linebreaks...
Image

Notepad++
Image

Brackets
Image

Atom
Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Wed Jun 01, 2016 7:12 pm

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/
B
8
S
1
Posts: 21
Reputation: 488

Post » Wed Jun 01, 2016 7:23 pm

..so.. something like this?
Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Thu Jun 02, 2016 11:06 am

Message: JoaoCesar can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
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.

Image

Here is the .capx: https://goo.gl/To7N3f

Please, don't mind the HTML formatting. :p
B
8
S
1
Posts: 21
Reputation: 488

Post » Sun Jul 23, 2017 10:08 am

Message: aramesh can only post plain text URLS until they have 500 rep. 3 URLS modified. Why?
korbaach wrote:Notepad ignoring linebreaks...
Image

https://notepad-plus-plus.org/ Notepad++
Image

http://brackets.io/ Brackets
Image

https://atom.io/ Atom
Image

hi
could you pls explain how do you save your data in a notepad file.i need this in my app.
B
3
Posts: 5
Reputation: 185


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 45 guests