question

Arindam Mahata avatar image
0 Likes"
Arindam Mahata asked Clair A edited

how to change label of flowitem as it exits a processor

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

FlexSim 18.0.0
labelsflowitems
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

·
Mischa Spelt avatar image
1 Like"
Mischa Spelt answered Clair A edited

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.

· 3
5 |100000

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

Arindam Mahata avatar image Arindam Mahata commented ·

thank you sir

0 Likes 0 ·
François G avatar image François G commented ·

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 0 ·
Mischa Spelt avatar image Mischa Spelt François G commented ·

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;
}
1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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