Home› Programming
Discussion
Back to discussions page
Prasanna
Posts: 56 Apprentice
sending strings via socket |
422 views
|
Answered | |
/ Most recent by Prasanna
in Programming
|
6 comments |

in Programming
Hi,
i want to send the variable value through socket. but i cannot.
For example, a=10
socket_send_string("move(a)")
instead of receiving move(10), i received move(a).
correct me if am wrong.
Note: UR3 e series controller
i want to send the variable value through socket. but i cannot.
For example, a=10
socket_send_string("move(a)")
instead of receiving move(10), i received move(a).
correct me if am wrong.
Note: UR3 e series controller
Tagged:
Best Answers
-
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,261 Handy
The reason is you are sending the string of “move(a)”, this doesn’t automatically equate to “move(“ + a + “)”. The program does not know that you want to concatenate a variable inside that, you will need to tell it this using script functions from UR.<div>a=10 </div><div>Msg= str_cat(str_cat(“move(“,a),”)”) #Msg would be “move(10)” now </div><div>socket_send_string(Msg) #No quotes, we are sending the value of the variable Msg</div>
Make sense? -
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,261 Handy
So the UR function str_cat, takes two arguments, so you would just continue to nest the functions together to get enough arguments.
Also, UR does not allow the use of `+` with strings like other languages do, string manipulation is actually a fairly recent addition to the script language, I think 3.8 but it may have been 3.7.
So for example:a = 10 b = 20 c = 30 msg = str_cat(str_cat(str_cat(str_cat(str_cat(str_cat("move(",a),","),b),","),c),")") #Result of msg is move(10,20,30) socket_send_string(msg)
sorry to disturb you
How to concatenate 3 variables
like "move(a,b,c)"
Any idea on the below link
https://dof.robotiq.com/discussion/1573/error-in-socket-open/p1?new=1