Universal Robots Forum

Creating a text string including variable value information?

In URScript is there a way to create a text string including variable value information? For example:

“Value var1 returned”

where var1 is a variable.

Strings in URScript does not support concatenation or indexation.
Hence, you cannot directly store a variable value in a string.

Consider using XML-RPC or other interfaces to perform this type of operations.
A sample of XML-RPC calls for concat is found under samples.

You can also write a concatenated string to the UR logfile using the script function textmsg()

Cute! I never thought of that.

Here is a little nodejs server that we wrote with a conactenation function. We actually have an URScript API that we have written for interacting between the robot and our cloud connector, we are working on moving all of that functionality to an XML-RPC server so that it is easier to maintain over time versus keeping up a URScript API library.

var xmlrpc = require('xmlrpc')
var _ = require('lodash')
var PORT = 6968
var serverOptions = {
  port: PORT

// Creates an XML-RPC server to listen to XML-RPC method calls
var server = xmlrpc.createServer(serverOptions)
// Handle methods not found
server.on('NotFound', function(method, params) {
  console.log('Method ' + method + ' does not exist');

server.on('concatenate', function(err, params, callback){
  var returnValue = ""
  _.forEach(params, function(value) {
    returnValue += " " + value
  callback(null, returnValue)
console.log('XML-RPC server listening on port 9091')
1 Like

@mbush @jbm
Thanks. I’m new to xml-rpc but am quickly discovering the power -have been throwing more and more functionality into the server we’ve started to interface our vision software with UR.

1 Like