Forums > MaxMSP

comma problem

January 27, 2010 | 1:10 pm

Is there any way to insert a comma into a list for a message box?

If you have a list: 2000 0 100

Can you insert a comma after 2000 (2000, 0 100) so you can send it from a messagebox as a ramp for line~ ?

This is a problem I have come across many times
In this case I wanted to store a bunch of ramp messages in a coll object

0, 2000 0 100
1, 100 0 300
2, 4000 0 100
3, 2000 0 700
4, 300 0 600
5, 7000 0 400
6, 1500 0 200
etc

But coll lists can only take one commas pr line(after the indexnr), so I need to insert it after I have sent one list from coll


January 27, 2010 | 1:41 pm

hi,

try something like this :

– Pasted Max Patch, click to expand. –

g


January 27, 2010 | 1:43 pm

You can do it like this with sprintf. I’ve heard that combine is better to use for efficiency reasons, but I couldn’t get it to work with a comma. Anyway, there is nothing to worry about at all unless you’re using loooads of them. You could modify the patch by storing the chosen list for line in [zl reg ] and banging it when you want to trigger the ramp instead of every choice triggering it.

– Pasted Max Patch, click to expand. –

January 27, 2010 | 1:44 pm

Ahh, go with GE’s method. Much more elegant solution.


January 27, 2010 | 2:10 pm

oh, sorry for not mentioning. Im using 4.5 :( Any chance of posting in old format? (or short explanation)


January 27, 2010 | 2:13 pm

About your suggestion with zl reg. Sometimes it can be desirable to constantly generating 3 random values (startpoint, endpoint, ramptime) Then you need to be able to format it with comma on the fly. Thats another example of the comma problem with messagebox
….. but I will look into sprintf (or your patches in old format…)


January 27, 2010 | 2:19 pm

re-hi,

here is the max 4 format :

#P window setfont "Sans Serif" 9.;
#P user number~ 86 261 125 276 9 3 3 2 0. 0. 0 0. 250 0. 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 86 231 32 196617 line~;
#P comment 75 66 100 196617 recall;
#P number 41 261 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 58 171 62 196617 prepend set;
#P newex 41 149 27 196617 t b l;
#P message 41 196 85 196617 1000 , 0 1000;
#P newex 41 231 40 196617 line 0.;
#P message 53 65 14 196617 1;
#P message 41 45 119 196617 store 1 1000 \, 0 1000;
#N coll ;
#P newobj 41 114 53 196617 coll;
#P comment 164 46 100 196617 store;
#P connect 10 0 11 0;
#P connect 5 0 4 0;
#P connect 5 0 10 0;
#P connect 4 0 8 0;
#P connect 6 0 5 0;
#P connect 1 0 6 0;
#P connect 7 0 5 0;
#P connect 6 1 7 0;
#P connect 3 0 1 0;
#P connect 2 0 1 0;
#P window clipboard copycount 12;

g


January 27, 2010 | 2:29 pm

Solved it with sprintf, argument %c sending it asci nr 44 (comma) from a messagebox. Thanks
(Evrard, still curious about yours) ……. oh there it came while I was typing….
Ok, then I learned something new about coll formating. Thanks for that as well

Speaking of that: What is the asci nr for (backslash) Key object showed 92, but sprintf translated that into "


January 28, 2010 | 1:26 am

You could just store them as normal lists and then use [zl rot 2], [zl slice 2] and patch both outlets to the [line] object. The comma in a message box simply sends the contents one after another.

lh


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