How to change a variable value from scriptWriter

To address the error you’re seeing, this is because you’re missing a quote. However, even if you put the other quote in, you would then be attempting to call the function deactivateCreateTicketState() from inside URScript (because it’s all inside a string). At this point your script generation will likely fail with an error similar to “function deactivateCreateTicketState() not defined.” It’s easy to forget/mix up functions that exist in java, and those that exist in URScript, so try to keep them straight.

As for why it’s executing constantly, that’s probably due to the program being set to loop infinitely, and this code existing in a URCapProgramNode. By contrast, you can also create Installation Nodes whose script is executed only once per press of the start button/save button. You could also try placing this node in the Before Start sequence (tap the main Robot Program and tap the checkbox saying “Add Before Start Sequence”) as I believe this code is also only executed once.

However, because you asked to be informed of a better way of doing this, I’ll leave you with this link:

It is a class that contains many useful methods that allow you to run snippets of URScript directly from Java. So essentially, you would put in your action listener something like

URScriptCommand.sendCommand("textmsg(blah blah blah)");

And this script would be executed right away, each time the button is pressed, without needing to actually run your program. If this sounds like something you’d be interested in, I can try to go into more detail, otherwise you can do some further research into this class file. But just know that it is possible to execute single lines of script (or any number of lines) as a direct result of interacting with UI components on the Java side.