Syntax for PartitionID in List.entries()

Syntax for PartitionID in List.entries()

clairekruppGhafari
Observer Observer
20 Views
5 Replies
Message 1 of 6

Syntax for PartitionID in List.entries()

clairekruppGhafari
Observer
Observer

[ FlexSim 22.2.2 ]

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?

0 Likes
Accepted solutions (1)
21 Views
5 Replies
Replies (5)
Message 2 of 6

clairekruppGhafari
Observer
Observer
BTW I made it a Global List, so that I could use list.entries().
0 Likes
Message 3 of 6

JordanLJohnson
Autodesk
Autodesk
Accepted solution

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

.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 4 of 6

clairekruppGhafari
Observer
Observer

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
Message 5 of 6

clairekruppGhafari
Observer
Observer

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
Message 6 of 6

JordanLJohnson
Autodesk
Autodesk

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.

.


Jordan Johnson
Principal Software Engineer
>