Global variable Array with Array elements

Global variable Array with Array elements

jarek_o
Not applicable
770 Views
5 Replies
Message 1 of 6

Global variable Array with Array elements

jarek_o
Not applicable

Hi,

I would like to make an Global Variable with type Array, containing Arrays as elements.

example:

Array[2]: Array("foo",1), Array("foo",2);

It doesn't seem to be that easy for me.

Flexsim version: 17.1.6

0 Likes
Accepted solutions (1)
771 Views
5 Replies
Replies (5)
Message 2 of 6

arunTTT2P
Collaborator
Collaborator
Accepted solution

Hi @Jarek O,

Here's a simple example.

First you create a global array variable manually, then you can insert array elements through code.

int rows = 5;
Array DataArray = [5,3,2];
Array array = Array(rows);
array.fill(DataArray);
GlobalArray = array;// GlobalArray is the global array variable

Regards,

Arun KR

0 Likes
Message 3 of 6

jarek_o
Not applicable

Is this working for you? For me it doesn't work, I tried similar things as well, but nothing that succeeds.

Regards,

Jarek

0 Likes
Message 4 of 6

arunTTT2P
Collaborator
Collaborator

yes, just see the return value on the script console.global-array.fsm9184-global-array.png

0 Likes
Message 5 of 6

jarek_o
Not applicable

yes @Arun KR, but it isn't stored in the GV? If you run that script, it returns indeed that array, but the global variable itself is still empty in further use.

Jarek

0 Likes
Message 6 of 6

arunTTT2P
Collaborator
Collaborator

I was able to reproduce the changed global array in a label array in a Queue.

But you will not see the value change in the tools menu of global variable.

Pls check the model. global-array.fsm