Simpler Genexpr

D1rty Duck's icon

If I work in Gen I heavily use the codebox, but sadly I couldn't finde too much documentation about it.
So I have the following code

if (in3 > 1.5){    
    if (in3 < 2.5){    
        n = in1;
        v = in2 / 127;
    }
}

In other languages like C++ you could use a statment like

if (in3 > 1.5 and in3 < 2.5) {...

Is there a way make something similar in gen as well? And if yes how do you do it?

👽'tW∆s ∆lienz👽's icon

yes, you can just combine them with a logical AND('&&'), like this:
if((in3 > 1.5)&&(in3 < 2.5))
{ n = in1; v = in2 / 127; }

D1rty Duck's icon

Thanks a lot.

👽'tW∆s ∆lienz👽's icon

no worries, happy to help :)
just wanted to mention also, not useful for your case here, but for other shorter forms of 'if', you can also use the 'ternary' operator and embed it within itself, my example here is not so smart but just to show the idea: