question

chiiiiii avatar image
0 Likes"
chiiiiii asked chiiiiii commented

assign labels by custom code

Hello, I have a question.

I would like to assign labels based on the status of a global table. Below is my code:

if (Table("outputstate").cell(2,2).value == -1 && Table("outputstate").cell(3,2).value == -1) {

token.item.outputport = 1;

}

else if (Table("outputstate").cell(2,2).value == -1) {

token.item.outputport = 1;

}

else if (Table("outputstate").cell(3,2).value == -1) {

return token.item.outputport = 2;

}

have verified that the values in the outputport table are correct. However, when Table( "outputport")[2][2] =1 and Table( "outputport")[3][2] =-1, the assigned label should be 2, but in reality, it is assigned as 1.

I would like to know if this approach is feasible, or if there is an error in my code. I would really appreciate your help!

Thank you very much!

FlexSim 24.2.2
processs flowassign label
· 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
0 Likes"
Felix Möhlmann answered chiiiiii commented

I suppose you use this code in an Assign Labels activity? For the last case you wrote "return item.outputport = 2". The returned value is what will be assigned to the label. And here you return (item.outputport = 2) which gets evaluated as true/1.

If this is indeed placed in an Assign Labels activity, only use "return 1;" or "return 2;" in each case. Otherwise remove the "return" from the last case.

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