question

Ryosuke S avatar image
0 Likes"
Ryosuke S asked Ryosuke S commented

Retrieving the number of partitions in the global itemlist

I want to retrieve the number of partitions in the global itemlist, and I try to reference the itemlist like this

treenode n = getvarnode(List("ItemList1"), "partitions");
return /**/n.subnodes.length/**direct*/;

However, I get error as below at the first line.

Could not resolve getvarnode overload based on passed parameter.

What is the correct solution to this?

FlexSim 20.1.3
flexscriptflexsim 20.1.3statistics collectoritemlist
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

You'd need to cast the list as a treenode - at the moment it's a List type:

treenode n = getvarnode(List("ItemList1").as(treenode), "partitions");
 return /**/n.subnodes.length/**direct*/;
2 Likes 2 ·
Ryosuke S avatar image Ryosuke S Jason Lightfoot ♦♦ commented ·

@jason.lightfoot Thank you!

0 Likes 0 ·

1 Answer

Aida Chaikh avatar image
1 Like"
Aida Chaikh answered Ryosuke S commented

Hello @Ryosuke S,

You can try using this code:

return Model.find("Tools/GlobalLists/ItemList1>variables/partitions").subnodes.length;
· 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.

Ryosuke S avatar image Ryosuke S commented ·

@Aida Chaikh Thank you!

0 Likes 0 ·