SEND TO n° 6 with adjustment

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Spaggio86
Posts: 12
Joined: Sunday 16 March, 2014 - 15:15

SEND TO n° 6 with adjustment

Post by Spaggio86 »

Hallo everyone!!!!

Just a simple question. I have a queqe with a particular way to manage the products inside. I use the "send to" function number 6 (By atom name:if the atom name of the 1st atom in the queue matches "XXX" than send to channel 1 else 2) but I have to make a change. I want the atoms different by "XXX" are sent in channel 2 or 3 or 4 randomly...

What can I have to do to reach my purpose?

Thanks in advance!!!
Nick
Posts: 48
Joined: Saturday 15 February, 2014 - 01:52

Re: SEND TO n° 6 with adjustment

Post by Nick »

Hi Spaggio86,

The predefined logic you selected uses the following 4DScript code:

Code: Select all

if(CompareText(Name(Rank(1,c)),[AtomName]),1,2)
You can use the function dUniform to generate a random discrete value between 2 and 4.
In other words, if the atom name of the 1st atom in the queue doesn't match "XXX", then use dUniform(2,4)

Regards, Nick
Spaggio86
Posts: 12
Joined: Sunday 16 March, 2014 - 15:15

Re: SEND TO n° 6 with adjustment

Post by Spaggio86 »

Thanks Nick, i used that code with the dUniform distribution and it works!!!

I start to understand this language...
Post Reply