question

Claire Krupp avatar image
0 Likes"
Claire Krupp asked Jordan Johnson commented

Syntax for PartitionID in List.entries()

I am trying to grab the token in a list partition so that I can get the current value of the label "NumSheets". (It would also work if I can just grab the value of NumSheets directly from the list.)

I am using list.entries() but no matter what I put inside the () (nothing, a number, or a string) it tells me that the list is empty.

Here is my test code and the status of the list when I am executing the script:

1673022524155.png

I have tried entries(), entries(1), and entries("nsLEPE1"), but it always comes back with len of 0.

What is the proper syntax?

FlexSim 22.2.2
list entries
1673022524155.png (17.8 KiB)
· 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.

Claire Krupp avatar image Claire Krupp commented ·
BTW I made it a Global List, so that I could use list.entries().
0 Likes 0 ·

1 Answer

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Jordan Johnson commented

I wonder if the partition is a node value, so you need to use

WIPList.entries(Model.find("nsLEPE1"))

If the partition value is a string value, then the screenshot you shared is missing a "1" on the end of "nsLEPE1".

· 3
5 |100000

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

Claire Krupp avatar image Claire Krupp commented ·

Thanks @Jordan Johnson , the "Model.find" did not work, but the typo correction did!

Hopefully it will still work when I pass in "token.ProcessName" instead of the text string.

But then in line 7

Object WIPtoken = WIPlist.entries("nsLEPE1")[1].value;

gives an "Invalid down cast" error.

I copied the placement of the [1] from the user manual, but maybe something else is needed?

Or is the value on the list (a token) not an Object?

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Claire Krupp commented ·

Use "Token" instead of "Object"

Token WIPToken = WIPlist.entries("nsLEPE1")[1].value;

The values on the list are tokens rather than objects. You can tell because the value field shows "instance" and "id", which it only does for tokens.

1 Like 1 ·
Claire Krupp avatar image Claire Krupp commented ·

I changed the Object to Token and now line 7 works, but

int numsheets = WIPtoken.NumSheets;

is bombing out with no error message...

I had to use

int numsheets = WIPtoken.labels["NumSheets"].evaluate();

So, for anyone following this, the correct syntax is

List WIPlist = List("List: Pallets at nsLEPE");
int len = WIPlist.entries("nsLEPE1").length;
if (len>0){
    Token WIPtoken = WIPlist.entries("nsLEPE1")[1].value;
    int numshts = WIPtoken.labels["NumSheets"].evaluate();
    return numshts;
//
}





0 Likes 0 ·