Forums > MaxMSP

### incdec and umenu; avoid negative item numbers??

Sep 13 2012 | 3:57 pm

Hi blokes, and birds,
using a hardware version of [incdec] object (one momentary button for UP, one for DOWN), I would like users to be able to scroll through my [umenu] of 41 different scales. Using the Max [incdec] I can get 0-1-2-…..40-0-1-2… on a loop, using the up/inc command (and [% 41]). Scrolling DOWN however, with the down/dec command I can only get as far as 0. Then the negative numbers increase. What I would like is infinite looping from 0….40 in any direction. Any help? Maybe the [%] is part of the problem?

Thanks
Brendan

ps I tried [abs], but it results in just 0 or 1 when decrementing past 0.

Sep 13 2012 | 4:12 pm

the % is the problem, you need to use a different formula to make the "looping" work for negative numbers.
either you perform a split at -1/0 and have a different "modulo" for negative numbers:

expr (((\$i1%\$i2)+(\$i2)*((\$i1%\$i2)==0))*(\$i1>=0))+(((((\$i1%\$i2)+\$i2)+(-\$i2)*(((\$i1%\$i2)+\$i2)==0))*(\$i1<0)))

or alternatively you could use a simple offset to shift the range for a bigger amount into positive:
+ 1,000,000,000 -> % -> – 1,000,000,000.

-110

Sep 13 2012 | 5:04 pm

if the look of incdec isn’t so important, why not use a few other basic objects?

``````
-- Pasted Max  Patch, click to expand. --

```
```
Sep 13 2012 | 6:00 pm

Both viable suggestions, but I’ll go with either the simpler of Roman’s (+ 1,000,000,000), or Andrzej’s delightful use of [counter] + direction commands.

Thanks guys

Brendan

Sep 13 2012 | 6:01 pm

I had the same problem but I wanted it to stay within the limits of the range so I did this:

``````
-- Pasted Max  Patch, click to expand. --

```
(When I first looked and Andrzej’s patch I was like, "woah, what objects are those!")
edit – posted wrong patch
```
Sep 13 2012 | 9:11 pm

Couple of more ways of solving the puzzle. Put your umenu in a coll or loop a table.

``````
-- Pasted Max  Patch, click to expand. --

```
```
Sep 14 2012 | 4:06 pm

Thanks for these gents. Yeah, I was a little confused/concerned at first, who knew you can click "through" a comment? For some reason, the + button reminds me of a Messerschmitt wing/fuselage marking, so I changed it so as not to offend……….. Myself. ?

Brendan

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

Forums > MaxMSP