how to change label of flowitem as it exits a processor

how to change label of flowitem as it exits a processor

arindam_mahata
Not applicable
71 Views
4 Replies
Message 1 of 5

how to change label of flowitem as it exits a processor

arindam_mahata
Not applicable

[ FlexSim 18.0.0 ]

we can use setlabel on exit trigger but my problem is not about changing labels of all the flowitems exiting.suppose there are two items having label say "A" with values 1 and 2 and i want to change the value of item having "A" value=1 to 3.plz help

0 Likes
Accepted solutions (1)
72 Views
4 Replies
Replies (4)
Message 2 of 5

mischa_spelt
Advisor
Advisor
Accepted solution

If you use the standard "Set Label" trigger option, and click the little 'Code' button to its right, the code-behind for that option will open and show you a line such as

involved.labels.assert(labelname).value = value;

which does the actual setting of the label.

You can change this to something like

if(involved.labels.assert(labelname).value == 1) {
  involved.labels.assert(labelname).value == value;
}

where the additional if clause will check if the current value is equal to 1 or not.

Or you can replace the whole code by something simpeler

Object item = param(1);
Object current = ownerobject(c);
int port = param(2);


if(item.LabelOnItem? == 1) {
	item.LabelOnItem = 3;
}

but then you will not be able to modify it from the popup anymore.

Message 3 of 5

arindam_mahata
Not applicable

thank you sir

0 Likes
Message 4 of 5

francois_g
Not applicable

Hello @Mischa Spelt ,

I tried to use your code to change just one label of one product as asked in the question at the top. So I wrote the code below but nothing happened with my flowitem. The Labelname of my first item stayed at 1 after processing.

I also used your second code : Label name doesn't change.

Have you another solution to suggest ?

Thanks for your response

if(involved.labels.assert(labelname).value == 1) {
  involved.labels.assert(labelname).value == 3;
}
0 Likes
Message 5 of 5

mischa_spelt
Advisor
Advisor

Hi Françios. In the second line, you have a comparison instead of an assignment. Replace the == by an =.

Actually you don't need to assert the label twice: when you get into the if it will definitely exist so you can just write it as

if(involved.labels.assert(labelname).value == 1) {
  involved.labels[labelname].value = 3;
}