Forums > MaxMSP

need coll help – indexing w float

December 13, 2009 | 6:46 pm

so, i’m using this coll jitcell config in my patch, nothing too weird. what i need to do is have the index numbers be floats. since coll won’t accept that, any ideas for a work around to have the first number of the list line (the float)not repeat, or replace the line if that float has already been entered (ie, act like the index)?

thanks!
drew


December 13, 2009 | 7:36 pm

You could multiply the float you want to use as the index by 1000 and then using an integer version of the result as the index to coll… this would preserve 3 decimal places. Use greater powers of 10 for more precision.

Eddy


December 13, 2009 | 8:08 pm

thanks; it’s a good idea, but then the jitcel portion of my patch (through refer coll) displays the multiplied number, not the float i need.

still brainstorming . . .


December 13, 2009 | 10:05 pm

not sure if this is what you want to do, but you can have the float be a symbol in the coll:

– Pasted Max Patch, click to expand. –

December 14, 2009 | 1:38 am

damn, i’m using max 4.6 and can’t see you’re doing. coll stores things beginning with an index, and a list of whatever and the index can’t be a float. i can have my float be the first number after the index, but i need to find a way of making that float unrepeatable (no duplicates), or in the event a duplicate is made, it replaces the first instance. is there and object, similar to [urn] that filters numbers?

drew


December 14, 2009 | 3:17 am

bbracken, i totally apologize. using [tosymbol] absolutely works. is there a way to limit the extra zeros [tosymbol] creates?

drew


December 14, 2009 | 4:55 am

something like this?

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 17 193 72 196617 prepend store;
#P newex 96 193 32 196617 print;
#P newex 17 156 62 196617 pack s hello;
#N coll foos;
#P newobj 17 224 53 196617 coll foos;
#P newex 45 101 62 196617 prepend set;
#P message 45 129 50 196617 3.21;
#P flonum 17 39 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 17 61 102 196617 sprintf symout %.2f;
#P connect 5 0 7 0;
#P connect 5 0 6 0;
#P connect 7 0 4 0;
#P connect 0 0 5 0;
#P connect 0 0 3 0;
#P connect 3 0 2 0;
#P connect 1 0 0 0;
#P window clipboard copycount 8;


December 14, 2009 | 5:12 pm

yep, right on the money. unfortunately, using this method, i’m now having issues deleting items from the coll. neither the remove nor delete message doesn’t seem to work with the symbol. am i missing something?

and forgive my manners, i appreciate the help – the symout worked great (thanks for that)! i wasn’t familiar with it at all. makes me think how many other command phrases i’m missing. any reading to recommend?

drew


December 14, 2009 | 5:33 pm

Drew,

You have to do some rounding/symbol making before you pump it into the coll. Another sprintf will be your friend:

#P window setfont "Sans Serif" 9.;
#P flonum 137 144 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 137 168 102 196617 sprintf symout %.2f;
#P newex 137 191 75 196617 prepend delete;
#P newex 16 192 72 196617 prepend store;
#P newex 95 192 32 196617 print;
#P newex 16 155 62 196617 pack s hello;
#N coll foos;
#P newobj 16 223 53 196617 coll foos;
#P newex 44 100 62 196617 prepend set;
#P message 44 128 50 196617 0.07;
#P flonum 16 38 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 16 60 102 196617 sprintf symout %.2f;
#P connect 5 0 7 0;
#P fasten 5 0 6 0 21 182 100 182;
#P connect 0 0 5 0;
#P fasten 0 0 3 0 21 88 49 88;
#P connect 9 0 8 0;
#P connect 10 0 9 0;
#P fasten 8 0 4 0 142 215 21 215;
#P connect 1 0 0 0;
#P connect 3 0 2 0;
#P connect 7 0 4 0;
#P window clipboard copycount 11;


December 14, 2009 | 5:54 pm

my whoops. i jumped right in to combining the symout message with the remove message via [sprintf %s %s]. that’s a bad argument. thanks again!


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