Page 1 of 1

Robot send to, script

Posted: Tuesday 05 July, 2016 - 13:53
by Emilhaglund
Hi,

I am trying to write some 4d script code for a robot. What I want is that products will be sent to a "server1" through output channel 1 if "server1"'s status is IDLE and to a second server through output channel 2 if "server1" is BUSY. I have written the following code that produces different messages in order for me to understand what values are being returned.

Do(

var([st5],vbstring,statusname(status(out(1,c)))),
msg(st5),
if
(
st5=[Idle],
msg([1]), msg([2])

)
)

For the first product the messages "IDLE" and later "1" appears. For the 2nd product the message is "BUSY" or sometimes "BLOCKED" and later "1" againg apperars. For the 2nd product the status of "server1" is not IDLE but the 2nd message displayed is "1" and not "2". Why and how can i fix it? would be grateful if someone could help

/Emil

Re: Robot send to, script

Posted: Wednesday 06 July, 2016 - 11:13
by HarryBunnik
Ha Emil,

What I notice in your code is that you try to compare text using an equal ("=") sign. In Enterprise Dynamics you have to use CompareText to make a comparison between strings. An equal sign can only be used for values. So it would result in:

Code: Select all

CompareText(st5, [Idle])
Another way might be to compare it using the values. This has the advantage that it is faster. For a small model the effect is not that big, but it is something to take into account. ;-)

I hope this helps you a bit further!

Cheers,

Harry