Skip to main content

Hi;

How and in which transformers is it possible to implement the documented mathematical function if() in a text or arithmetic editor?.

As a result, I always get <null>.

Thank you.

Oh that's interesting... there is an if() function in the documentation, but it doesn't show up in the math functions list. @mark2atsafe​ I think this might be a bug. I can't get it to work so I'm wondering if it's maybe not implemented fully.

 

You can use Conditional Values to achieve the same thing as the if() function does, hope that helps.


Thanks for the quick reply.

I know I can use conditional value, but for more complicated conditions it would be easier for me to manually write expressions in the editor.

I hope that conditional statments in the editor will be fully implemented soon.

Thanks again.


Hi @rzrnc​ , in my understanding, you can use the @if(,,) function only in RasterExpressionEvaluator and PointCloudExpressionEvaluator. 

You can use the ?: operator to calculate conditional value in any math expression instead. This expression returns B if A is true, C otherwise.

A ? B : C

 

However, there is no way to do a similar operation in a string expression.

Vote this idea if you like.

Add StringTemplater transformer or add Template Functions to StringConcatenator

 


You can also use math operators to do some basic conditional statements directly, e.g.

@fmod(@Value(number),2)==1 ? "odd":"even"

http://docs.safe.com/fme/2019.2/html/FME_Desktop_Documentation/FME_Workbench/!Transformer_Parameters/math_operators.htm


I'll check with the developers, but my guess is that this no longer works. Or it works in a completely different way from what we expect. In fact, I'm not sure where it comes from since there is no IF operator in C arithmetic. But as others have said, the ternary operator (A ? B : C) works absolutely fine.


Reply