Forums > MaxMSP

#0 to int within a subpatch

April 30, 2006 | 8:11 pm

I need to collect the value associted with #0 in a subpatch and convert it
to int. I am sure I’ve done this before and thought one of these worked…

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 215 140 51 196617 tosymbol;
#P number 215 189 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 215 164 27 196617 int;
#P message 218 120 24 196617 $0.;
#P number 81 192 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 82 153 27 196617 int;
#P message 84 123 24 196617 $0.;
#P connect 6 0 4 0;
#P connect 3 0 6 0;
#P connect 4 0 5 0;
#P connect 0 0 1 0;
#P connect 1 0 2 0;
#P window clipboard copycount 7;

Cheers,
Gary Lee Nelson
TIMARA Department
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson


April 30, 2006 | 8:26 pm

hi gary. i did not load your patch in max, but looking at the text patch
it seems you have put a "." after #0 (why?).. i believe this is what’s
causing the problem.

jm


April 30, 2006 | 8:29 pm

hi gary,

maybe your memory converted the fromsymbol to a tosymbol ;-)

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 275 200 64 196617 fromsymbol;
#P number 275 249 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 275 224 27 196617 int;
#P message 275 174 24 196617 $0.;
#P connect 1 0 2 0;
#P connect 3 0 1 0;
#P connect 0 0 3 0;
#P window clipboard copycount 4;

jan klug


April 30, 2006 | 8:35 pm

Well duh…maybe I’m getting too old for this. :-)

Thanks, Jan

Cheers,
Gary Lee Nelson
TIMARA Department
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson


April 30, 2006 | 9:23 pm

how dumb of me to not have open the patch.. but you didn’t answer my
question about why you put a dot after #0?? is there something i’m missing?

jm


April 30, 2006 | 9:36 pm

> why you put a dot after #0??
>

that’s what i also thought, but when i tried it out it appeared that
max makes a $0 out of the #0 if there’s nothing attached to it;
gary’s method seems to be a nice workaround for this!

jan


April 30, 2006 | 9:40 pm

Actually the "." is what makes this possible. A "#0" all by itself turns
into a "$0" I DON’T know the answer to this. A "#0." becomes perhaps
"1001." which is a symbol. fromsymbol turns it into a float and int
converts it to the integer I need. Someone taught me this trick a year ago
and I remembered the "." but misremembered the fromsymbol as tosymbol.

Cheers,
Gary Lee Nelson
TIMARA Department
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson


April 30, 2006 | 11:09 pm

Actually someone else get credit for this. I posted a query to the list and
this was the solution I received. Sorry I don’t remember who that kind soul
was.
Cheers,
Gary Lee Nelson
TIMARA Department
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson


April 30, 2006 | 11:29 pm

oh wow, very interesting! i usually use the "#0-whatever" method to give
unique names to objects and then truncate to just the 1001 value if i
need the value by itself. never knew about the dot thingee.. so much easier!

this has got to be the best max tip i got in along time, thanks!

jm


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