question

Axel Kohonen avatar image
0 Likes"
Axel Kohonen asked Axel Kohonen commented

What is the best way to pass parameters in the onMessage trigger to a user command?

Hi,

We generally have the onMessage triggers of our objects call a onMessage... user command so that we can manage the code for multiple objects in the same user command instead of editing each object's message trigger separately. Currently we are parsing the 3 parameters that you get by calling msgparam(1), etc. into doubles which we then pass on to the user command.

Now when FlexSim supports variants, is using doubles still the way to do it or should one parse the message parameters as variants and pass them on as variants instead when passing them to a user command?

The code below seems to work and so does also using variants with TASKTYPE_SENDMESSAGE.

var test = 5;
senddelayedmessage(current, 0, current, test);

Thank you!

Kind regards,

Axel

FlexSim 16.2.0
user commandmessage triggervariant
· 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.

Jeff Nordgren avatar image Jeff Nordgren commented ·
0 Likes 0 ·

1 Answer

Phil BoBo avatar image
1 Like"
Phil BoBo answered Axel Kohonen commented

Just pass the return values from the functions directly. In your OnMessage, do this:

return myOnMessageUserCommand(current, msgsendingobject, msgparam(1), msgparam(2), msgparam(3));
· 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.

Axel Kohonen avatar image Axel Kohonen commented ·

Hi Phil,

Great! Thank you!

Axel

0 Likes 0 ·