question

anon-user avatar image
0 Likes"
anon-user asked Marco Baccalaro answered

Use "if" function to change labels

Hello,

I'd like to do an "actual-target-comparison" by checking whether the value of a label is equal to another label. If it's true, then change another labels value to 1. See my simplified code snippet below. If I try to apply the code like this to my model it won't work and gives back an error message regarding the syntax. I am quite new to programming custom code in FlexSim and don't get how to adress labels on items. In the end this costum code is implemented in a decision point on a conveyor in order to send items one way or another.

/**Custom Code*/
Conveyor.DecisionPoint current = param(1);
Object item = param(2);
Conveyor conveyor = param(3);
Conveyor.Item conveyorItem = conveyor.itemData[item];

if(item.labels["Anzuchtszeit_IST"] == item.labels["Anzuchtszeit_SOLL"])
{
    item.SollErr = 1;
}
FlexSim 18.1.2
labelsdecision pointsif
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

Marco Baccalaro avatar image
4 Likes"
Marco Baccalaro answered anon-user commented

Change the "if" line to:

if(item.Anzuchtszeit_IST == item.Anzuchtszeit_SOLL)

or

if(item.labels["Anzuchtszeit_IST"].value == item.labels["Anzuchtszeit_SOLL"].value)
5 |100000

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