wrong content function in trigger on exit of a queue

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Alex
Posts: 5
Joined: Thursday 14 February, 2013 - 16:22

wrong content function in trigger on exit of a queue

Post by Alex »

Hey guys,

I have a serious problem with a content statement in a trigger on exit in a queue.

The situation: I would like to perform a certain statement in a trigger on exit of a queue when the queue is going to be empty. The problem is that although the queue has over 400 products, my statement tells me, that there are no products in it.

Code: Select all

do(
 if(
  Content(c)<1,
  do(...),
  do(...)
 )
)
To check where the problem is, I have tried the following statement:

Code: Select all

do(
 if(
  Content(c)<1,
  Trace(string(content(c)))
 )
)
The tracer underlines the fact, that the content(c) function returns 0 in this case.

If I try

Code: Select all

Trace(content(c))
everything is fine and the right number of products is traced.

I do not see the problem, why the first two statements restunr the wrong number of products?

Thanks for your help.
Alex
User avatar
MatthijsJongboer
Posts: 200
Joined: Thursday 11 November, 2010 - 14:12

Re: wrong content function in trigger on exit of a queue

Post by MatthijsJongboer »

Hello Alex,

Your initial statement seems to be correct.
The trigger on exit is fired when the product causing it has left the queue. Therefor, this product is not included and the queue is either empty or not.
Your seconds chunk of code will always return 0.
Find here some code that always returns something on exit:

Code: Select all

do(
 if(
  Content(c)<1,
  Trace(concat([queue is empty: ], string(content(c)))),
  Trace(concat([queue is not empty: ], string(content(c))))
 )
)
So your initial code should work.
If you keep struggling, attach a simple model that demonstrates the incorrect behavior.

Matthijs
Alex
Posts: 5
Joined: Thursday 14 February, 2013 - 16:22

Re: wrong content function in trigger on exit of a queue

Post by Alex »

Hey Mathijs,
thank you very much for your fast answer! Although it is very helpful I had the solution for my problem while having lunch... ;)
Just as you mentioned, the proudcts where to fast. The first four products went through and filled other atoms which caused the statement to be executed. After the fourth product the queue began to fill and the statement worked correctly... so everything is fine for the moment.

sorry for making such a big thing out of it but sometimes the mistake is to easy...

thank you very much
Alex!
Post Reply