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

Sep 13, 2012 at 3:57pm

# incdec and umenu; avoid negative item numbers??

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.

#39783
Sep 13, 2012 at 4:12pm

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

#140237
Sep 13, 2012 at 5:04pm

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

– Pasted Max Patch, click to expand. –
#140238
Sep 13, 2012 at 6:00pm

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

#140239
Sep 13, 2012 at 6:01pm

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

#140240
Sep 13, 2012 at 9:11pm

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

– Pasted Max Patch, click to expand. –
#140241
Sep 14, 2012 at 4:06pm

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

#140242

You must be logged in to reply to this topic.