question

stefano L avatar image
0 Likes"
stefano L asked Joerg Vogel edited

How to store field values from a list into an array

Hi, I'm trying to store field values (not the header) from a list into an array. In particular, I pushed items in a list called ListBox and now I want to store values of Dimension field into an array.

Is there a way to do it?

Thank you in advance for your answer.

FlexSim 19.0.0
listarraylist fieldsarray_agg
cattura.jpg (55.1 KiB)
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

·
Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Joerg Vogel edited

You can get access to the list entries by a table.query and the clause ARRAY_AGG()

Array myArray = Table.query("SELECT ARRAY_AGG(Dimension) FROM ItemList1")[1][1];

this is shortest way to get the entries of a field of a list.

My first Approach is a bit longer. You do a Table.query for the List. Then you clone the result table into an array. Unfortunately the array is 2-dimensional. You append each result cell value in a one dimensional array by an iter( ..) - ation.

The table.query works only on global lists.

global-list-field-to-an-array.fsm


· 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.

Joerg Vogel avatar image Joerg Vogel commented ·
Array myArrayAlt = Table.query("SELECT $2",
	rslt.length, 
	myArray.push(rslt.shift()[1])).clone()[1][1];

an alternative source code line

1 Like 1 ·
stefano L avatar image stefano L commented ·

@Jörg Vogel Thank you for your answer, I'm using a global list. How can I do it by script?

0 Likes 0 ·

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.