Forums > MaxMSP

How to output desired numbers

March 26, 2008 | 4:24 am

Hi. I was wondering if there was an object that you could specify what numbers to look for and when it received them, to output that number. Kind of like [select] except instead of outputting a bang it would output the number it was looking for. I know how to do this with a combination of different objects but I thought there should be a way with just one object. Maybe there is external that I don’t know about or maybe I’m missing something. Thanks for your help.


March 26, 2008 | 4:55 am

On Mar 25, 2008, at 9:24 PM, Theo wrote:
> I was wondering if there was an object that you could specify what
> numbers to look for and when it received them, to output that number.

Split sort of does this.

Chris Muir
cbm@well.com

http://www.xfade.com


March 26, 2008 | 5:07 am

>I know how to do this with a combination of different objects but I thought there should be a way with just one object. Maybe there is external that I don’t know about or maybe I’m missing something.

Best to abandon the notion that there is

a. only one way to do almost anything in Max
b. there is a single object that will perform any arbitrary task

early on. These two notions won’t serve you well. In my
experience it’s best to think about what kinds of data
you’re trying to test or compare, and what you want to
do with it [and whether you might not want to do a
couple of things with the data later on], etc.

If you’ve got single object fever, why not make yourself
an abstraction? You’ll probably want this again.


March 26, 2008 | 5:38 am

Thanks to both of you. I took both of your guys advice and I made an abstraction using split. Here it is in case you are interested.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 262 210 62 196617 split $5 $5;
#P newex 210 183 62 196617 split $4 $4;
#P newex 158 156 62 196617 split $3 $3;
#P newex 106 129 62 196617 split $2 $2;
#P newex 54 102 62 196617 split $1 $1;
#P inlet 54 70 15 0;
#P outlet 138 267 15 0;
#P connect 1 0 2 0;
#P connect 2 1 3 0;
#P connect 6 0 0 0;
#P connect 5 0 0 0;
#P connect 4 0 0 0;
#P connect 3 0 0 0;
#P connect 2 0 0 0;
#P connect 3 1 4 0;
#P connect 4 1 5 0;
#P connect 5 1 6 0;
#P window clipboard copycount 7;


March 26, 2008 | 9:55 am

I’d make something like this slightly more general like below, so it will have some more uses.
Oh, and in this case there is a single object that does it: zl sect

#P window setfont "Sans Serif" 9.;
#P number 442 183 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 442 148 76 196617 zl sect 1 4 7 9;
#P number 442 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P outlet 321 277 15 0;
#N comlet list of numbers to let through;
#P inlet 249 45 15 0;
#P newex 249 67 85 196617 unpack 0 0 0 0 0;
#P newex 269 217 62 196617 split $5 $5;
#P newex 217 190 62 196617 split $4 $4;
#P newex 165 163 62 196617 split $3 $3;
#P newex 113 136 62 196617 split $2 $2;
#P newex 61 109 62 196617 split $1 $1;
#N comlet number to be checked;
#P inlet 61 45 15 0;
#P outlet 61 277 15 0;
#P connect 11 0 12 0;
#P connect 10 0 11 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P connect 3 0 0 0;
#P connect 4 0 0 0;
#P connect 5 0 0 0;
#P connect 6 0 0 0;
#P connect 7 0 2 1;
#P connect 7 0 2 2;
#P connect 2 1 3 0;
#P connect 7 1 3 1;
#P connect 7 1 3 2;
#P connect 3 1 4 0;
#P connect 7 2 4 1;
#P connect 7 2 4 2;
#P connect 4 1 5 0;
#P connect 7 3 5 1;
#P connect 8 0 7 0;
#P connect 7 3 5 2;
#P connect 5 1 6 0;
#P connect 7 4 6 1;
#P connect 7 4 6 2;
#P connect 6 1 9 0;
#P window clipboard copycount 13;


March 26, 2008 | 12:17 pm

Hey thanks. That is a better way of doing it. Also, I looked at the help file and the manual and it doesn’t say anything about zl sect and how you can specify specific numbers to output. But anyways that is awesome and thank you very much.

Quote: Bas van der Graaff wrote on Wed, 26 March 2008 03:55
—————————————————-
> I’d make something like this slightly more general like below, so it will have some more uses.
> Oh, and in this case there is a single object that does it: zl sect
>
> #P window setfont "Sans Serif" 9.;
> #P number 442 183 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P newex 442 148 76 196617 zl sect 1 4 7 9;
> #P number 442 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P outlet 321 277 15 0;
> #N comlet list of numbers to let through;
> #P inlet 249 45 15 0;
> #P newex 249 67 85 196617 unpack 0 0 0 0 0;
> #P newex 269 217 62 196617 split $5 $5;
> #P newex 217 190 62 196617 split $4 $4;
> #P newex 165 163 62 196617 split $3 $3;
> #P newex 113 136 62 196617 split $2 $2;
> #P newex 61 109 62 196617 split $1 $1;
> #N comlet number to be checked;
> #P inlet 61 45 15 0;
> #P outlet 61 277 15 0;
> #P connect 11 0 12 0;
> #P connect 10 0 11 0;
> #P connect 1 0 2 0;
> #P connect 2 0 0 0;
> #P connect 3 0 0 0;
> #P connect 4 0 0 0;
> #P connect 5 0 0 0;
> #P connect 6 0 0 0;
> #P connect 7 0 2 1;
> #P connect 7 0 2 2;
> #P connect 2 1 3 0;
> #P connect 7 1 3 1;
> #P connect 7 1 3 2;
> #P connect 3 1 4 0;
> #P connect 7 2 4 1;
> #P connect 7 2 4 2;
> #P connect 4 1 5 0;
> #P connect 7 3 5 1;
> #P connect 8 0 7 0;
> #P connect 7 3 5 2;
> #P connect 5 1 6 0;
> #P connect 7 4 6 1;
> #P connect 7 4 6 2;
> #P connect 6 1 9 0;
> #P window clipboard copycount 13;
>
—————————————————-


March 26, 2008 | 2:04 pm

Another way of solving it: (though zl sect works just fine)
If you’re using ints, you could use coll. Store new values into it
using message box with the message "$1 $1". When you send a single
value in, coll will output it if it contains that index. Won’t work
with floats, however.

Peter McCulloch


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