question

Patrick Cloutier avatar image
0 Likes"
Patrick Cloutier asked Matthew Gillespie commented

How to reference values in an array in a table cell

I have global tables for which the cell format is array so that I can put many values in each cell.

What is the correct syntax to reference a specific value in an array in a cell?

For exemple, I reference the cell with Table("Interventions")[i][5] but that gives me the whole cell content. I just want to reference one value in the array in the cell.

By default all arrays in every cell have the same name: Array[1]

Thanks,

FlexSim 20.0.2
tablesarrayreference
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

·
Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Matthew Gillespie commented

Here are a few ways you could do it:

return Table("Interventions")[i][5].as(Array)[2];
Array array = Table("Interventions")[i][5];
return array[2];
return Table("Interventions").cell(i, 5).value[2];
· 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.

Patrick Cloutier avatar image Patrick Cloutier commented ·

When I write this (with an index of 1) it returns the whole array.

If I put an index greater than 1, I get "Array index out of bounds".

And all my arrays have a length of at least 3.

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Patrick Cloutier commented ·

Do you have an array of length 3 inside another array of length 1?

You said "By default all arrays in every cell have the same name: Array[1]". That looks like you only have length 1 arrays in the table.

Maybe you should attach the model?

0 Likes 0 ·
Jacob Gillespie avatar image Jacob Gillespie ♦ Patrick Cloutier commented ·

Maybe you are mistaken in how you think the array is set up?

It sounds like you have an array inside an array.

0 Likes 0 ·
Patrick Cloutier avatar image Patrick Cloutier Jacob Gillespie ♦ commented ·

All methods return the same problem. Might be the way the array is setup in the table.arrays.fsm

Here is my simplified model. The code is in the "Find room" box.

0 Likes 0 ·
arrays.fsm (244.2 KiB)
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.