Nested If?
How do write a nested if in Max? I want to set values greater than 127 = 127, values less than 0 = 0, and pass them on otherwise. I'm trying this:
Seems simple enough but...
Thanks,
J
Quote: neridaj@gmail.com wrote on Fri, 13 July 2007 11:48
----------------------------------------------------
> I want to set values greater than 127 = 127,
> values less than 0 = 0, and pass them on otherwise.
Er ... [clip 0 127] ?
i *think* you can do "if ... and if" in [expr], if thats
not true, you could also use 2 if expressions in series.
for the task you have to do i would probably also use
[clip 0 127] yet i trtied to anser the question about "if".
On 13 juil. 07, at 01:48, Jason wrote:
> How do write a nested if in Max? I want to set values greater than
> 127 = 127, values less than 0 = 0, and pass them on otherwise. I'm
> trying this:
>
> max v2;
>
If can't do that, the resulting statements are not evaluated so it
won't work. As mentioned by everyone, clip is certainly the most
efficient way of doing that. But you can do it that with some kinda
nested if (in the ? : operand form) in jstrigger. I'm not sure that
I'd be able to read that tomorrow;-)
ej
In general I will use the "else out2 $f1" approach to do nested ifs (but
in this specific case clip will do the trick, as pointed out already):
Best,
Trond
> How do write a nested if in Max? I want to set values greater than 127 = 127, values less than 0 = 0, and pass them on otherwise. I'm trying this:
>
> max v2;
> #N vpatcher 20 74 620 474;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 251 312 246 196617 if $f1 > 127 then 127 else if $f1 < 0 then 0 else $f1;
> #P pop;
>
> Seems simple enough but...
That did the trick, thanks everyone.
J