2024-01-19 04:07 PM
Hi, we are using a property that should return a length IF another (boolean) property is set. Basically if the other property is true that means this object has a certain sub object and its length should be calculated according to certain criteria.
I've managed to create a working IF clause basically like this:
IF (other_property = TRUE;
calculation for length;
0 mm)
But instead of returning 0 mm if the other property is false, I would simply like this property to return as undefined, or NULL or something like that.
Solved! Go to Solution.
2024-02-27 12:49 PM
FALSE is basically a 0 while TRUE is a 1. So if you try to put FALSE as a result into your expression, it still has a value, while you intend to not have a value at all.
Thats why IFS is working. You just define, what happens if your condition is = TRUE, while not defining (undefined) what happens if your condition is = FALSE.
A bit offtopic but as a bit of additional information to IFS. It's still possible to define what happens, if your condition is = FALSE. It would like this:
IFS(Condition1; ValueIfTrue1; [Condition2; ValueIfTrue2];[...];[Conditionⁿ; ValueIfTrueⁿ]; TRUE; ValueIfNoConditionIsMet)
2024-01-22 11:35 AM
Hi
you might try the following:
IFS(other_property = TRUE;
calculation for length)
2024-02-27 10:58 AM
Thank you, this works in this instance. But is there no more generalized way to return an undefined/null value? I don't know the syntax for this expression language. I did manage to achieve the same result by returning "FALSE", but it comes with the error "Data types and units must be identical for all predefined output values" and I'm slightly worried this might cause issues further down the line.
2024-02-27 11:07 AM
You can't mix data types.
You are asking if a condition is true, then calculate the 'length', but if it is false you want a 'string' ("Null" or "Undefined").
I think the best you will get is to return a zero (0) length.
Then the data type will always be 'length' and you not get an error in the expression.
Barry.
2024-02-27 11:12 AM
Not quite, I don't want a string saying "Null" or "Undefined", I would simply like the value of this property to be undefined. When editing properties in objects there is the option to manually set a property as "undefined", and that makes it behave in a certain way. I would like to be able to set the property to undefined via an expression too.
2024-02-27 11:19 AM
OK then.
Can you set the default for that property as 'undefined'?
Then use the expression that Xandros suggested.
Then it will hopefully remain 'undefined' unless the expression is true.
I am not really sure as I haven't played a lot with expressions in this way.
Barry.
2024-02-27 11:28 AM
If i set the default to undefined then you can't use expressions. I'll use the expression Xandros suggested or FALSE, unless anyone else knows more. It is not critical to our project but I though I'd ask since many other programming languages have some version of NULL och Undefined that can be the value returned from functions. Thanks for the interest.
2024-02-27 12:49 PM
FALSE is basically a 0 while TRUE is a 1. So if you try to put FALSE as a result into your expression, it still has a value, while you intend to not have a value at all.
Thats why IFS is working. You just define, what happens if your condition is = TRUE, while not defining (undefined) what happens if your condition is = FALSE.
A bit offtopic but as a bit of additional information to IFS. It's still possible to define what happens, if your condition is = FALSE. It would like this:
IFS(Condition1; ValueIfTrue1; [Condition2; ValueIfTrue2];[...];[Conditionⁿ; ValueIfTrueⁿ]; TRUE; ValueIfNoConditionIsMet)
2024-02-27 01:16 PM
Thanks for the extended explanation!