text to textedit (display and edit entire txt file, including carriage returns)

Shane's icon

This is likely a very simple matter, but I haven't been able to figure it out, and I can't find the answer in forums...

I am trying to open a text file with the [text] object (using a "read" message) and pass it to a [textedit] object (with "dump"). This works fine in principle, but if the txt file has carriage returns/multiple lines, only the last line will be passed to [textedit].

How can I get it to display all lines of the text file for editing?

PS: I know I can use the internal text editor instead, but this is not an option, as I am trying to include the [textedit] interface in presentation mode along with some other interface items, and as far as I know there is no way to control the position of the internal text editor and integrate it with presentation mode.

Shane's icon

This thread from 2010 has gotten me a lot closer: https://cycling74.com/forums/display-text-with-carriage-returns

In particular, Luke Hall's suggestion that "Sending the number 10 to [itoa] will output a newline character" solves the problem that I was only getting the last line.

There are a few remaining oddities, though:

1) If there are two carriage returns in a row, only one of them will show up in textedit

2) A blank line is added at the beginning when text is dumped to textedit.

Can anyone help with these?

Thanks in advance!

Shane's icon

Looks like I figured it out, in case it is of interest to anyone:

minutes-editor.maxpat
Max Patch

Source Audio's icon

a bit different, adds newline before adding lines.

ignoring first one.

Shane's icon

Thanks, this is really helpful!