question

Patrick Cloutier avatar image
1 Like"
Patrick Cloutier asked Matt Long commented

How to reference item that was previously in processor

When items enter a processor I need to check if its a different product than the previous one. And if it is different I need to label the previous one to say that it was the last of that batch. I need that info down the line. I do that check in the Input Pull Requirement.

My problem is that when I check the product coming in, the other one has already left so I can't reference it anymore and label it. And I can't either check in the next objects because the item isn't there anymore and I can't predict where it is now.

I put a pointer label (lastitem) on the processor that records that last node that went through and that works. But then when I try to add a label to that node it doesn't work:

current.lastitem.labels.assert("yourelast").value=1;

Can this work?

Otherwise how could I reference something like "last item that was here" or "previous item" ?

Thanks a lot,

FlexSim 17.1.4
previous item
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

Matt Long avatar image
1 Like"
Matt Long answered Matt Long commented

I think you're doing the right thing, putting a label on the processor that points to the last item. I'm not sure why your code wouldn't be working. It looks correct and works in a simple test. You can also just say:

current.lastitem.yourelast = 1;

This will assert the label as well.

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

Patrick Cloutier avatar image Patrick Cloutier commented ·

I found out why it didn't work. It's not a processor, it's a Separator so I was putting the label on the empty container. So I added if (port==2) before setting the pointer label on the separator.

Is there a time when we need to use assert ?

1 Like 1 ·
Matt Long avatar image Matt Long Patrick Cloutier commented ·

Using labels.assert("LabelName").value is probably only useful if your label name has spaces or special characters in it. In that case, using object.Label Name is not valid and using object.labels["Label Name"].value will throw an error if the label doesn't exist.

The assert is probably most useful when you need to get the label node as opposed to the value. You can also use the assert("LabelName", defaultValue) method that lets you define a default value to set the label to when it's created.

1 Like 1 ·