the strange output of textedit

Nov 25, 2011 at 1:08pm

the strange output of textedit

Does anyone understand the output of textedit when it includes commas and semicolons?

I’ve got a textedit box with the text
To be or not to be, that is the question;

If I send its output to [print], I get
To be or not to be, that is the question ;
(Note the space inserted before the semicolon, but not before the comma)

If I send the output to another textedit box (after [route text]->[prepend set]) it copies perfectly, ie no space before the semicolon. (BUT: if I put a space before the semicolon in the original, it disappears in the second text box!)

If I send the output to [tosymbol @separator |], the punctuation disappears completely:

[zl nth 7]->[print] prints “be”, but [zl nth 8]->[print] does not print at all
[zl nth 12]->[print] prints “question”, but [zl nth 13]->[print] does not print at all

If I send the output to a [js] object, its anything() function receives both the comma and the semicolon as 0.

What’s going on?

Here’s a patch that demonstrates all this:

– Pasted Max Patch, click to expand. –

And here’s the javascript for the [js reportargs] object (this didn’t format right when I put it in backticks):

// posts the message passed to it, with arguments delimited by |

autowatch = 1;
inlets = 1;
outlets = 0;

function anything()
var output = messagename;
for (var i = 0; i < arguments.length; i++) {
output += “|” + arguments[i];
post(output); post();

Nov 25, 2011 at 3:49pm

indeed, extra spaces will get removed when passing messages around of all kinds, and if Max finds a semicolon or comma, the behavior varies depending on where the message is going. Try putting quotes around the whole thing and see the differences: spaces are maintained, and the semicolon won’t move.

Backslashes before commas and semicolons will preserve them, but typically you won’t put them into a [textedit] when typing…not sure if there’s an automatic way to add them. If you don’t use the bang to report the text, and you rely on the ASCII ouput while typing to build your message (a pain), then you could do it, but you might as well be using [key].

It definitely takes a lot of fiddling to figure it all out…

Nov 26, 2011 at 4:30am

Yes, in fact I’ve found the Output as One Symbol setting, which does what you’re talking about without requiring quotes around the text. This preserves all spaces etc, and will be my ultimate solution, but I’m still curious about what’s happening with that comma and semicolon. What exactly is being passed in that list that
[tosymbol] doesn’t seem to detect at all, that [zl] knows is there at position 8 and 13 but can’t pass on to [print], that javascript sees as 0s, but that is recognized by [print]???


You must be logged in to reply to this topic.