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


  1. List myList = List("ItemList1");
  2.  
  3. int myListLength = myList.stats.content.value;
  4.  
  5. //loop through all list entries
  6. for(int listEntry = 1; listEntry <=myListLength; listEntry ++)
  7. {
  8. var listItem = NULL; //How to get reference to item.
  9. int itemType 0;
  10. }
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.

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.