Universal Robots Forum

Secondary Client Issue

Hi

I would appreciate some help with sending multiple lines of script from a button in our URCap. We can send a single line like a popup or setting an output but multiple lines are not working. We are using the “ClientSendScript” class. To try and find the problem I am simply sending two lines of script within the def end statement but only the second line works. When I’ve tried more than two lines it is still only the last line that is executed.

In the screenshot below you can see the command that is sent each time the button is pressed in the terminal and the effect on the output state in Polyscope. What am I doing wrong? I’m sure it must be something simple but I’ve been trying for hours without luck.

I can see from here


that others have had this issue but using a def statement should be the answer but it’s not working

Here is the method that produces the string that goes to the script sending class

screen2

And here is the sending function

screen3

Thank you for your time

Regards

Matthew

You shouldn’t use writeUTF function - according to documentation it adds lenght before string. You should use

out.writeBytes(thisCommand);
out.write(thisCommand.getBytes("US-ASCII"));

Also remember about indentation rules when you send scripts directly to the socket. You can find these in latest URScript documentation in section 1.2.

2 Likes

Thank you very much. That worked very well