question

qoie200011 avatar image
0 Likes"
qoie200011 asked Julie Weller commented

Custom Code in Global List

Hi there,

I’ve encounter some problem when setting up the field of global list. I want to choose the expression and record which number of processor group the item is assigned to go to. That is, the item has the information label of group number. For this, I have set the destination label as current.inObjects[1].



The token received the label as:

item: /Processor8/Box

puller: id:31


And I also set a label on processor to denote the number of group as the picture below:

I came up with some idea of the custom code as below:

if (value.destination.group==1)

return 1;

elif (value.destination.group==2)

return 2;

elif (value.destination.group==3)

return 3;

elif (value.destination.group==4)

return 4;

else

return 0;


Since I’m new to Flexscript that I’m not sure if this kind of expression will work. Thanks for your help!

FlexSim 23.0.9
custom codeglobal list
圖片1.jpg (19.4 KiB)
· 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.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Jason Lightfoot commented

There is no "elif" in FlexScript. If group and return value are equal then you can return the label value directly. The "?" makes it so FlexSim will not throw an error if the label does not exist on the object but instead just return 0.

  1. return value.destination.group?
· 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.