String replacement and escapement in generateScript() with writer.assign() function

Hello,

I have a daemon function with multiple String arguments as:

myFunction(arg1, arg2, arg3)

I am calling this function properly outside the generateScript function. I am also executing properly other daemon functions with a single argument from generateScript. However, with more arguments I’ve got the error “myFunction() takes exactly 3 arguments (1 given)”. So, I assume that is a syntax problem…

Well, I am trying to execute that function as:

String scriptString = “testCommand, 192.168.0.1, 2222”;

writer.assign(“daemonResponse”, getInstallation().getXMLRPCVariable() + “.myFunction("” + scriptString + “")”);

Is there any error? How should a multiple arguments be set? Thank you.

1 Like

Hi,

yes, there is an error.

your function is taking 3 arguments, but you are only passing a single string argument.

something like this should work:

writer.assign(“daemonResponse”, getInstallation().getXMLRPCVariable() + “.myFunction(“+“testCommand” +, + “192.168.0.1”+,+ “2222”);

Hi,

This syntax is not working. According with the documentation, for writer.assign(String, String), you have two string arguments.
The first one is the name and second one the command. So you can only set the command with multiple arguments as a string sentence, like I posted.
If writer.assign() supports more that one argument, what is the correct syntax? thanks

No the documentation is correct, however the program cant tell the difference between a string with commas and a function delimiter. What I forgot to add was that you need a backslash to tell that it is a string value:

This might not be 100% correct, but it is mostly there:

writer.assign(YOUR_VARIABLE, “myfunction(\“testCommand”, \“192.168.0.1”, + \“2222\”)”);