Display text with carriage returns
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.
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…
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.
Sending the number 10 to [itoa] will output a newline character, here’s an example:
----------begin_max5_patcher---------- 537.3ocwVFsbiBBEF9Z8ofwqyti.pwr2sOGc5zgnrozQQGkLMsc56dgCwI1c ocwnI4hHwCH7ym+mi7VXPz1lC79HzuP2gBBdKLH.BYBDb79fnZ1ghJVOLrHE +fhWJTQqrcJJgvMae5G37gf+oQpjrZNz0u6Drpgdj6qExJtBlL7ofM6UCQSF MI8hWgIAS9Y7wvsLUwiB4tG53EJqxwwltQ37bnIN1zjpuht+3CYmd0Ksb6SD EsBEIjJSC7CcuYfuGFZtrxSVTy66Y63C6MCZf3EUbVmK.sdh.h3DP3ICnLKe xRMMz0VX8s34r3gj+rda9O3PnZXtnQ5DoAcgnAl.FDLErKIYlqju0sXbJKIQ TnJsM0ESRVjTHxYmBgGYQHdkAsjboSuJbTO2Y0ExsEManPUEOIyhhk1NdKWV hXslFWrAuHrAe11lL.Nax8.NKZk1x80st3Q7MpPKltApoXqrfuTEZ+JbzwYt rGzaEMrtCKMnoW4O6.+wg2XQRUnmKLVi88iNlxHaYxcNKzBOVTkP92mdCVYS 7OCr9l8cECy7vYQPmV8RduRHYJQib7fx+zfdTTVxg9G1m0hx1Fs3NJB8lK07 N19pFe5tu38p2hM1GwNMsh01Rs7xxGo0r7YKU5xqz4BOeTD45JI7Ev7MWMk5 illpIirAxAxhGmQjEO+LB8AEQ3+mZSutDL4BPv4pIhOZJYFZRey6gevYco2u -----------end_max5_patcher-----------
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?
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.
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:
----------begin_max5_patcher---------- 385.3ocqSEzaBCBE9b6uhld1IZssw3MSl2zKKamVVVnsOsXnfAnwtY7+9JTo qN0nayKOfuuG793iG6bc7S3Ufz2ah2qdNN6bcbLPZ.mCqc7KvUoTrzjlOC1x SV62qgRAUJCLkiyRvrUVBRlAtN0GBhsfK4LECW.FpoBBlZYXkE7REETlhL7. ZCj5iMPiB8MUv6sNGmj7ogbXP+AGf2fUo4D1p2EPppYiizrdACzw3A14sGTc 0Ir1hqw165pC8tQSY8VH4b27nqey0NXJmxEMJsUSkBpI4kDJLAgPuHAgDUHK U4ffhR4Y.ZAtZNIQfEDPhddwbjLG8zroOtXVeU86xuyaupu1QkC0V3Qg1MeQ 2OdrNFNNRODEDeO8+BPJwqfS5JE.NSafdm5JcelBuaMn+8lyvPiSNJ1LL9Rt SPG2wjgOkv94OXSQz3GaYRdoH0pT6OSuuKTFHUDFVQ3rtIEdTR4jrLvvauRE jrMbBSIscvm8A7l0T3snon+glpWr28K.mJ8JZA -----------end_max5_patcher-----------
This patch will read the README file in whatever directory it is located.
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.
Forums > MaxMSP