question

martin.j avatar image
0 Likes"
martin.j asked martin.j commented

Strange Flexscript exception.

I have encountered a rather disconcerting error in my current model. When running a specific code loop, the script quits unexpectedly with an exception when using continue. I thought it might be due to some of these weird errors and faulty behavior that creeps in over time when making large models, so I copied a few tables and the script to a new model, but the same thing occurred.

Please see the attached model: The script in the scripting window runs a loop with two if (expression) continue; clauses in them. But at certain points the code quits when reaching these continue clauses. Not only is it a problem in this specific code, but it shakes my trust in the overall stability of flexsim coding. What if similar behavior happens in other places?

The error occurs on line 30 after the loop has run to 944 iterations, so to catch it a break point is set on line 14. What is really strange is that if I comment line 18 (it does nothing in the script logic anyway) the error starts occurring on every iteration but on line 22 instead.

looperrormodel.fsm

FlexSim 17.1.4
flexscript errorexception message
screenshot-2.jpg (76.5 KiB)
looperrormodel.fsm (1.3 MiB)
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
2 Likes"
Phil BoBo answered martin.j commented

The issue is with the new compiled FlexScript debugger.

When you aren't debugging, this code is compiling and executing correctly.

When you are debugging, the program is compiling and executing each statement one at a time. The code for continuing in the for() loop is not correctly handling the local Table reference (cellTab) defined within the loop's scope but after the continue statement.

I'll add a case to the development list to fix this bug.

In the meantime, you can get around this bug by moving your Table cellTable declaration outside of the for() loop scope or above the continue statements within the for() loop scope.

· 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.

martin.j avatar image martin.j commented ·

Thanks Phil! I would have never discovered this on my own. I appears that there are still a few issues about creating tables in nodes other than actual tables. I tried to create a table with some rather large values in a token-label and consistently caused flexsim to crash when I clicked the token.

0 Likes 0 ·