question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Ankur A3 commented

Array Label is Not Showing Values

Hi Team,

I am generating tokens and appending values to array. But array is not showing values as [1,2,3,.....].

1652588778608.png

Can you help to understand what is going wrong here?

ArrayLabelNot ShowingElements.fsm

Thank you!

FlexSim 21.0.10
arraylabelvalues
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
1 Like"
Felix Möhlmann answered Ankur A3 commented

'append()' adds an array to the end of another array. In your code, you are passing in a number though, which gets interpreted as an (empty) array with a length corresponding to the number.

Either pass in the number as an array of length one by enclosing it in [] brackets. Or use array.push instead, which is used to add values to the end of an array.

array.append([Counter]);
array.push(Counter);
· 5
5 |100000

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

Hi @Felix Möhlmann,

Thanks for your answer but it is not working as I was expecting [1,2,3,4,5......................].

While pushing elements to array, array size is not increasing. It is only coming as 1 and showing the last pushed value.

1652672926359.png

1652672791607.png

It will be helpful if you can attach working model.

Thank you!

0 Likes 0 ·
1652672791607.png (18.7 KiB)
1652672926359.png (4.1 KiB)

To get the effect you describe you need to assign the clone of a global array to the token using this :

Counter+=1;
return counterArray.push(Counter).clone();

where counterArray is a global variable of the array type.

arraylabelnot-showingelements_jl.fsm

1 Like 1 ·
Ankur A3 avatar image Ankur A3 Jason Lightfoot ♦ ·

Thank you so much @Jason Lightfoot!

It is working same as I was expecting.

Still I have one question if I can. Why it is not working same (local array is only showing 1 element) with local array variable?

Thank you!

0 Likes 0 ·
Show more comments

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.