if/then/else sentence

damian's icon

hi,

( first at all, my English is not good. )

I'm trying to do the following:

if $i1 >= 13 then out=$i1-12 else $i1

" out=$i1-12 "
how can I do that?

I just want numbers over 12 to be subtracted by 12.

is it clear?

the solution I find is using the i$2 with one more object with the $i1-12 expr, so...

if $i1 >= 13 then $i2 else $i1
where $i2 is "$i1-12"

but... i'm sure there is a way to do this with one single "if sentence", isn't it?

thnks,
damian.

Darwin Grosse's icon

why not just do something like this - it seems easier to me:

I'll have to admit that, with if statements, I probably use the
"out2" bit more often than not.

[ddg]
Darwin Grosse

Steven Miller's icon

Depending on what you're doing (there was no info on the context of
what this is for) you might just be looking for %12 (modulo 12) -
this just gives you the remainder after dividing by 12.

Max Patch
Copy patch and select New From Clipboard in Max.

----
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home
SFIFEM
Atrium Sound Space
OVOS
CMP

Jakob Riis's icon

>I just want numbers over 12 to be subtracted by 12.

I would do it like this:

Max Patch
Copy patch and select New From Clipboard in Max.

/J

jr.abstractions for MaxMSP - new version (2008-01-15)
http://www.sonicescape.net/maxmsp/

damian's icon

thnks a lot.

"Modulo operator" seems to be perfect.