Skip to main content
Question

Math function if(arg1,arg2,arg3)


rzrnc
Participant
Forum|alt.badge.img+2
  • Participant

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.

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

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.


rzrnc
Participant
Forum|alt.badge.img+2
  • Author
  • Participant
  • March 8, 2022

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.


takashi
Influencer
  • March 8, 2022

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

 


ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • March 8, 2022

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


mark2atsafe
Safer
Forum|alt.badge.img+44

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings