question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Matthew Gillespie commented

Exception: Conditional Value evaluates both options

The new parser is a bit stricter, throwing exceptions in cases it did not use to before. In principle this is great, however it led to an issue with the default "Conditional Value" item in - in this case - a Process Flow Assign Labels activity.

We wanted to find the center object of an object, if any, otherwise assign null. So we used the Conditional option:

which produces the same code as it has always produced:

int condition = /** \nCondition: *//***tag:expression*//**/current.centerObjects.length > 0/**/;
Variant value1 = /** \nIf Condition is true: *//***tag:true*//**/current.centerObjects[ 1 ]/**/;
Variant value2 = /** \nIf Condition is false: *//***tag:false*//**/nullvar/**/;


return condition ? value1 : value2;

Note that both alternatives are evaluated in value1 and value2, and based on the condition one of them is returned. However, this leads to the issue that even when the condition is false, we try to evaluate

current.centerObjects[ 1 ]

and we get an exception. We manually changed the code to

return /** \nCondition: *//***tag:expression*//**/current.centerObjects.length > 0/**/
? (/** \nIf Condition is true: *//***tag:true*//**/current.centerObjects[ 1 ]/**/) 
: (/** \nIf Condition is false: *//***tag:false*//**/nullvar/**/);

Before this was not a problem, because even if the object did not have center connections, evaluation of

var value2 = centerobject( current, 1 );

would simply assign the "invalid-node" pointer to value2 without throwing and then return value1.

TL;DR: bug report / feature request: avoid evaluating all alternatives in Conditional activities. The same probably goes for other activities such as By Percentage.

FlexSim 17.0.3
bug reportconditional
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

I've added this bug report to the dev list.

0 Likes 0 ·

1 Answer

·
Matt Long avatar image
0 Likes"
Matt Long answered

This has been fixed in version 17.0.4.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.