question

Mark Gormley avatar image
0 Likes"
Mark Gormley asked Jeanette F commented

Loop through list entries in FlexScript

Hi, I am sure this is really simple, but cannot find a similar post or entry in the help.

How do I loop through a list and access the field values in FlexScript, without pulling the items first?
In the example below i want to access the item in the list itself as well as its type label stored on the item.

Thanks

Mark


List myList = List("ItemList1");

int myListLength = myList.stats.content.value;

//loop through all list entries
for(int listEntry = 1; listEntry <=myListLength; listEntry ++)
{
var listItem = NULL; //How to get reference to item.
int itemType 0;
}
FlexSim 22.0.11
list
· 1
5 |100000

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

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Mark Gormley, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered Jason Lightfoot commented

You can get an array of entries through List.entries(). Through the entries you can then get the associated value. If the list values are objects you can thus also access their labels this way.

To read other field values you would instead query the list with Table.query() and use the resulting table to access the field values.

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

https://answers.flexsim.com/answers/64417/view.html > query global list in tree to get all values over all partitions.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Joerg Vogel commented ·
For that you use List.entries(<partition>):

Documentation: List entries method.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Jason Lightfoot ♦ commented ·

@Jason Lightfoot, please read my linked answer. If you don't know any partition value attribute, then you must find them and filter each partition separately.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

Note: Fields with expressions referencing the puller will not work with Table.query.

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.