Test condition 0< var <1
Hello,
I tried using the [if...] fonction to test if a value is between 0 and 1 this way :
[if $f1 > 0. || $f1 < 1. then $f1 else 0.]
and it doesn't work
[if $f1 > 0. || $f2 < 1. then $f1 else 0.] works
But I can't find out how to make two test on the same $f1
Thanks )

Thanks I tried it but didn't work, I guess I made a syntax error elsewhare, works now. Great !
processingwise even faster is [expr ( ($f1>0.) && ($f1<) ) * $f1]
make sure wether you really need < and >, or rather >= and <=.
if you do not need "else 0" then [split] does it, too (but you probably know that.)
Thanks, works great ! Very simple way know wether one or several entries are non zero.
zero or nonzero can found by [if $f1] :)
while i personally would not write that... for readability.
zero or nonzero can found by [if $f1] :)
I wanted to try [if $f1] but it throws an error (missing then). So you need to do [if $f1 then 1 else 0]. But the shorter version is [!= 0.]
About [expr ( ($f1>0) && ($f1<1) ) * $f1], another much less readable version is [expr (abs($f1) - int($f1) == $f1) * $f1]. For the sake of the exercice, I tried to know which one is faster by repeating each operation a million times, but the result is... not consistent? Actually it seems to depend on position in patch, which makes no sense to me.
But we don't really care at that scale.
the [if] in max 4 is more tolerant. it interprets the missing condition as "if true/false" (which is the same as != 0 ) and the missing "then" as "then $f1".
sorry, i should have known that it stopped working long ago.
glad you tested it a million times at different positions in the patch.