text object, whitespace and stripping it

Jul 15, 2009 at 5:31pm

text object, whitespace and stripping it

Hi

I’m having some problems with text objects. I’m putting symbols into them one after the other and then dumping then later on to use, quite simple. However the text object seems to be automatically adding a white space at the end of each symbol input. I haven’t posted an example here but if you open the help patch for text you’ll see it does this. First question is there a way to stop this?

If not I’ll need to do a check on dump to see if each symbol output has whitespace at the start (just in case) and end. I did build a solution using strchr, strrchr and strrcut like so (the first valid character in my symbol is always < and the lat is >):

max v2;
#N vpatcher 20 74 620 474;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 156 139 27 196617 – 1;
#P outlet 116 291 15 0;
#P newex 116 226 38 196617 strcut;
#P newex 139 188 52 196617 strrchr >;
#P newex 139 116 47 196617 strchr < ;
#P newex 116 162 43 196617 strrcut;
#P inlet 116 68 15 0;
#P comment 130 69 62 196617 Input string;
#P user panel 32 37 180 70;
#X brgb 255 255 255;
#X frgb 255 0 0;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 129 292 55 196617 String out;
#P user panel 32 262 180 70;
#X brgb 255 255 255;
#X frgb 255 0 0;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 6 0 5 0;
#P connect 10 0 5 0;
#P connect 7 0 8 0;
#P connect 5 0 8 0;
#P connect 8 0 9 0;
#P fasten 4 0 6 0 121 113 144 113;
#P fasten 5 0 7 0 121 185 144 185;
#P connect 6 0 10 0;
#P pop;

which works well on short strings but crashes max on long ones, (I suspect there is a length limitation similar to zl here?). Is there a way to search for the first < and the last > and then trim?

Garrett

#44739

You must be logged in to reply to this topic.