question

Ben Walker avatar image
1 Like"
Ben Walker asked Matt Long answered

Trouble referencing global variables in process flow

I am having trouble using two code snippets back to back in the process flow. The tokens move right past both blocks of custom code. The code snippets are referencing global variables, which aren't being updated in the dashboard.

FlexSim 16.1.0
custom code
· 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.

Matt Long avatar image Matt Long commented ·

You haven't given enough information here to know what the issue is. Can you post your model?

1 Like 1 ·
Ben Walker avatar image Ben Walker commented ·

full.pngsnip1.pngsnip2.pnggv1.png

In this section of the process flow I am creating 4 tokens in "batch of 3" which makes 5 tokens that represent 3 objects. Next I am creating an object for the additional tokens that come through. I then change the size to look like three objects combined in "change visual" I then travel from one queue to another. Then the first code snippet will increment the contents of the queue. The second snippet will create a condition to reflect the availability of the first queue that was incremented earlier.

0 Likes 0 ·
full.png (6.9 KiB)
snip1.png (12.3 KiB)
snip2.png (10.6 KiB)
gv1.png (5.5 KiB)

1 Answer

Matt Long avatar image
2 Likes"
Matt Long answered

If you're referring to why your tokens 'jump' past the Custom Code activities when stepping, this is due to your Unload activity.

The task executer finishes its unload task, notifies the token it's complete and waits for the token to be released and execute whatever activities are next until it reaches an activity that causes the token to wait. The task executer is then able to continue on to its next task (or idle if no tasks remain).

In a nutshell, this seemingly odd jumping is important to keep the model logic executing in the same order whether you're running the model or the model is stopped and you're stepping. Certain activities like the task sequence activities 'lock' the model such that tokens move through multiple activities in one 'step'.

Your issue is due to the code you've written. The line

A1Contents = 0 && ProcessorA--;

is not two statements in one line, but instead is read by FlexSim to be a conditional or if statement. Instead you should write:

A1Contents = 0;
ProcessorA--;
5 |100000

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