Display text with carriage returns

    Dec 06 2010 | 8:24 pm
    I have some text stored in a .txt file. I can load it into a text object and when I double click on it, the text box appears and the text looks right.
    I'd really like to be able to display the same text in either a comment box or a textedit box, but it seems like it's impossible to display carriage returns. I've tried including \cr and cr in the text but it doesn't make a difference. Ideally I want to be able to send the message dump to the textobject and have it display the saved text file correctly somewhere on the patch. I realise dump outputs the text line by line, so all I'm getting so far is the final line being displayed.

    • Dec 06 2010 | 8:35 pm
      not sure, but couldn't you use [zl group] to put the text back together? this would of course mean that the text will be backwards (first line will be last line), but there should be ways around that too...
    • Dec 06 2010 | 10:48 pm
      I tried using zl group, but couldn't really get it to do what I wanted. It seems like to use it properly, you need to actually know how many words are in the file, which isn't useful in this case.
      I can actually output all the lines and have them written together by using append when passing it to the textedit object. But the lines are just put one after the other, and the carriage returns are ignored.
      I thought I would try setting Separator in the inspecter on the textedit object to cr and adding cr to the end of each line with an append object. Then I could bang the textedit object and output the text to another textedit object with the carriage returns in tact. But what it seems to do is just output the lines one after the other again and put it back exactly to how it was when it is dumped from the text object in the first place.
    • Dec 07 2010 | 2:01 am
      Sending the number 10 to [itoa] will output a newline character, here's an example:
    • Dec 07 2010 | 10:28 am
      Thanks Luke, that works perfectly now.
      I have just one more question though. Is it possible to scroll through text when it is too big for the textedit box? With a scrollbar or just with the mouse wheel?
    • Dec 07 2010 | 11:31 am
      Never mind I figured it out. In the end I've decided to use a jweb object with html files so I can format them more easily and have a scrollbar included.
      Thanks for the help.
    • Feb 05 2011 | 4:24 am
      Thanks for the suggestion to use jweb! I was looking for a solution for making a maxhelp patch that could display a README and thankfully the jweb "readfile" command honors relative paths, unlike the "read" command for other objects such as [text]. Astonishingly simple, here it is:
      This patch will read the README file in whatever directory it is located.
    • Feb 05 2011 | 1:14 pm
      As long as the file is in the max search path. I haven't checked how it deals with files in different directories with the same name.