Forums > MaxMSP

NewB Question: removing spaces

June 9, 2007 | 7:07 pm

Hi there. I’m really starting to get to a good place with Max/MSP, but this problem keeps coming up:

I’m trying to build flexible environments that can take one message and apply it to many. The example here is using pvar:

max v2;
#N vpatcher 67 279 1112 884;
#P origin 0 23;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 927 68 100 196617 etc…;
#P comment 715 70 100 196617 Module 2;
#P newex 732 172 69 196617 prepend fs1_;
#P newex 732 196 85 196617 prepend setname;
#P comment 768 470 100 196617 fs2_beta;
#P button 766 492 15 0;
#P objectname fs2_beta;
#P button 703 492 15 0;
#P objectname fs2_alpha;
#P newex 732 279 31 196617 pvar;
#P message 548 129 94 196617 setname fs2_alpha;
#P newex 732 147 49 196617 r module;
#P button 915 189 15 0;
#P window linecount 2;
#P comment 845 176 100 196617 this is in place of foot switch 2;
#P window linecount 1;
#P comment 665 471 100 196617 fs2_alpha;
#P window linecount 4;
#P comment 622 168 100 196617 this needs to not have a space or else setname reads an extra argument;
#P window linecount 1;
#P newex 276 170 69 196617 prepend fs1_;
#P newex 488 51 48 196617 loadbang;
#P newex 276 194 85 196617 prepend setname;
#P comment 312 468 100 196617 fs1_beta;
#P button 42 324 15 0;
#P message 42 345 64 196617 symbol beta;
#P newex 42 366 49 196617 s module;
#P button 310 490 15 0;
#P objectname fs1_beta;
#P button 247 490 15 0;
#P objectname fs1_alpha;
#P newex 276 277 31 196617 pvar;
#P message 92 127 94 196617 setname fs1_alpha;
#P newex 276 145 49 196617 r module;
#P button 459 187 15 0;
#P window linecount 2;
#P comment 389 174 100 196617 this is in place of foot switch 1;
#P window linecount 1;
#P comment 209 469 100 196617 fs1_alpha;
#P window linecount 2;
#P comment 64 317 100 196617 change to next message;
#P window linecount 4;
#P comment 166 166 100 196617 this needs to not have a space or else setname reads an extra argument;
#P window linecount 1;
#P comment 201 63 100 196617 Module 1;
#P connect 13 0 12 0;
#P connect 12 0 11 0;
#P fasten 16 0 7 0 493 78 97 78;
#P connect 6 0 17 0;
#P connect 17 0 15 0;
#P connect 15 0 8 0;
#P fasten 7 0 8 0 97 225 281 225;
#P fasten 5 0 8 0 464 225 281 225;
#P fasten 16 0 23 0 493 100 553 100;
#P connect 22 0 29 0;
#P connect 29 0 28 0;
#P fasten 21 0 24 0 920 227 737 227;
#P fasten 23 0 24 0 553 227 737 227;
#P connect 28 0 24 0;
#P pop;

The problem is, when I try to prepend, or append or use a symbol or ANYTHING in Max, it places a space between the two values. What I need is for something like fs1_alpha or alpha_fs1 or even fs1alpha, etc.

Is there any way to remove the space from the message? Otherwise I will have 40 separate sends and receives for each message. Alternatively, any other ideas would be welcome.

Thanks!
-Ben


June 9, 2007 | 7:27 pm

Try sprintf

e.g.:

max v2;
#N vpatcher 715 406 1009 581;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 222 61 47 196617 fs1_beta;
#P comment 157 61 53 196617 fs1_alpha;
#P button 237 81 15 0;
#P objectname fs1_beta;
#P button 174 81 15 0;
#P objectname fs1_alpha;
#P button 38 101 15 0;
#P message 62 57 29 196617 beta;
#P newex 26 79 119 196617 sprintf setname fs1_%s;
#P newex 26 34 48 196617 loadbang;
#P message 26 57 33 196617 alpha;
#P newex 26 123 31 196617 pvar;
#P connect 2 0 1 0;
#P fasten 4 0 3 0 67 75 31 75;
#P connect 1 0 3 0;
#P fasten 5 0 0 0 43 120 31 120;
#P connect 3 0 0 0;
#P pop;


June 9, 2007 | 7:40 pm

Brilliant! I didn’t even know it existed, but now it’s my new best friend.

Thank you!


Viewing 3 posts - 1 through 3 (of 3 total)