How to Get Value of Global Variable with Array?

How to Get Value of Global Variable with Array?

darwin_s
Not applicable
66 Views
2 Replies
Message 1 of 3

How to Get Value of Global Variable with Array?

darwin_s
Not applicable

[ FlexSim 19.0.9 ]

Hi

I'm trying to get the Value of Array From my Global Variable but the Script Always return Empty Array

Here is My Model

Added EDD_autosave.fsm

Here is the Code that i use (I used it in Object Accepted ) as Entry Trigger

31227-1595499238752.png

I already declared the Global Variable like This

31228-1595499295357.png

But it always Return Empty Array in the Code


Thank you

0 Likes
Accepted solutions (1)
67 Views
2 Replies
Replies (2)
Message 2 of 3

tanner_p
Not applicable
Accepted solution

@darwin.s,

Your model is trying to access the 0 index of the array, but it can't because in FlexSim, Arrays are 1-based. See the User Manual for more information.

I suggest setting the initial value of the "OrderArrayIndex" Global Variable to 1 instead of 0. Then the model should work just fine. I hope this helps!

31255-orderarrayindex.png

added-edd-autosave_1.fsm

Message 3 of 3

jeff_nordgren
Not applicable

@darwin.s,

Your model need a little more that just setting the OrderArrayIndex to 1. In the attached model, int the OnEntry trigger of Accepted, I added code to show you the values that are in the variables you are trying to use. And nothing ever gets put into your OrderSize array... it's empty. So in the line:

int PcNeeded = OrderSize[order-1];

PcNeeded is always equal to 0. So the following "if" statement is never true so it never increments the OrderArrayIndex value.

Just run the attached model and when it stops, just go through the code by pressing the Next Line button at the top of the code. That will step you through the code and show you what is in your variables.

added-edd-JN1.fsm