question

Laurenz Peleman avatar image
0 Likes"
Laurenz Peleman asked Laurenz Peleman commented

FlexScript exception: Invalid Variant types

Hi everyone

After updating a model from Flexsim 17.1.6 to 18.2.2 I got the following error:

exception: FlexScript exception: Invalid Variant types in + operation at MODEL:/Tools/ProcessFlow/MaterialTransport/Update feeds>variables/codeNode

, which is thrown for the following lines of code:

double valueToAdd = token.valueToAdd ;
token.labels.assert("feedToUpdate").value += valueToAdd;

Anyone who has experience with this error, as I have never received it before...

Kind regards

FlexSim 18.2.3
exception
5 |100000

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

1 Answer

·
Phil BoBo avatar image
3 Likes"
Phil BoBo answered Laurenz Peleman commented

You didn't specify an initial value for the label in the assert() command, so it isn't giving the label data.

You are trying to add (no data) with a (double), which throws an exception.

From the Release Notes of 18.2.0:

  • Changed Variant math operations on non-numbers to throw exceptions.

Pass 0 as the second parameter in your assert() call:

double valueToAdd = token.valueToAdd ;
token.labels.assert("feedToUpdate", 0).value += valueToAdd;
· 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.

Laurenz Peleman avatar image Laurenz Peleman commented ·

Thanks for the clear answer, @phil.bobo, I was not aware of that change

0 Likes 0 ·

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.