question

Prateekq4 avatar image
0 Likes"
Prateekq4 asked Felix Möhlmann commented

Flexscript exception on message trigger

hello everyone i am reframing my question as i was able to figure out what is going wrong. So I have set some conditions for processor 1 in my model such that on-process-finish trigger does closeoutput. Now when i set a openoutput condition in the on-message trigger, it showed an flexscript exception. The reason for this was that in the on-message trigger i am creating an if condition that looks at the item label value. Now if i remove the condition where it checks for my item label it works fine, but i do need it to check for my item label value. The item is referenced in the code as "Object item=param(5);". Do i need to reference in some other way?

FlexSim 22.0.16
onmessage trigger
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

·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

If you know when and where the error happens, you can set a break point in the code and step through it line by line, so see what exactly is going wrong.

In this case, you assign the "item" variable as the fifth trigger parameter. But the message trigger only supports four parameters. I don't know where the header of the trigger comes from (maybe an old version?), but you will have to update it. If the variable is supposed to point to the item that might currently be inside the processor, then you can use "current.first".

Then check if it actually exists with "if(objectexists(item))".

capture1.png


capture1.png (31.9 KiB)
· 2
5 |100000

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

Prateekq4 avatar image Prateekq4 commented ·
Hi Felix, thank you for the reply. I guess i just figured out the same thing that the item was the cause of the error. Would this work "Object item= current.first" .
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Prateekq4 commented ·
Yes, but as I said, you should check if there actually is an item in the processor before executing the rest of the code.
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.