Robot send to, script

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Emilhaglund
Posts: 1
Joined: Tuesday 05 July, 2016 - 09:43

Robot send to, script

Post 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
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Robot send to, script

Post 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
Post Reply