textedit output differentiation

Oct 7, 2007 at 3:57pm

textedit output differentiation

Hello

Trying to stop a textedit from outputting text when there is nothing to output (i.e. it’s empty) and I thought this would work:

max v2;
#N vpatcher 30 89 630 489;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 213 300 107 196617 print everything-else;
#P newex 126 299 54 196617 print text;
#P newex 66 299 55 196617 print bang;
#P newex 78 260 79 196617 route bang text;
#P user textedit 79 194 265 210 98320 3 9;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P connect 1 1 3 0;
#P connect 1 2 4 0;
#P pop;

but I can’t seem to get route (or select) to differentiate between text and a bang. It seems as if the bang is possibly not in fact a bang but “bang” (as text) – is this possible? What am I doing wrong here?

a+
gar

#34020
Oct 7, 2007 at 7:30pm

Garrett,

When textedit doesn’t have anything in it, it just sends out the messages “text”. Because everything coming out of textedit starts with “text”, the route sends everything through the 2nd outlet. Because route strips off the matching symbo, it has nothing to send out when the input is just “text”, so it sends a bang.

When I need to differentiate these two cases, I look at the length of the textedit output, like this:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 56 171 56 196617 route text;
#P newex 144 278 54 196617 print text;
#P newex 121 187 27 196617 + 1;
#P newex 61 276 67 196617 print nothing;
#P newex 76 217 38 196617 gate 2;
#P newex 104 112 27 196617 t l l;
#P newex 121 163 27 196617 > 1;
#P newex 121 134 34 196617 zl len;
#P user textedit 104 75 279 97 32896 3 9;
#P connect 8 0 4 1;
#P connect 3 0 8 0;
#P connect 4 1 7 0;
#P connect 4 0 5 0;
#P connect 0 0 3 0;
#P connect 6 0 4 0;
#P connect 2 0 6 0;
#P connect 3 1 1 0;
#P connect 1 0 2 0;
#P window clipboard copycount 9;

-Adam

#114310
Oct 7, 2007 at 7:40pm

I reread your original post and saw you just want to stop the output when it is empty. So here’s a simpler patch that should do exactly what you want.

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 85 237 54 196617 print text;
#P newex 85 213 56 196617 route text;
#P newex 85 191 29 196617 gate;
#P newex 104 112 27 196617 t l l;
#P newex 121 163 27 196617 > 1;
#P newex 121 134 34 196617 zl len;
#P user textedit 104 75 279 97 32896 3 9;
#P connect 5 0 6 0;
#P connect 4 0 5 0;
#P connect 2 0 4 0;
#P connect 3 0 4 1;
#P connect 1 0 2 0;
#P connect 3 1 1 0;
#P connect 0 0 3 0;
#P window clipboard copycount 7;

#114311
Oct 7, 2007 at 9:53pm

Hi

Thanks, works great, never even thought of checking the length of it to be honest I was trying to figure out how to check for a text that was empty or a “” (empty string) in programming – seems max does really have a quite peculiar logic all of its own.

a+
gar

#114312

You must be logged in to reply to this topic.