Creating global variable in generateScript

You can look up the example URCap for functionModel. I will give you details on how to use it. Essentially within the constructor of the program node you add functions to the function model. You would have a addFunction function to add a String functionName to function model. This is shown in the URCap example and another post I made in the past → [IMPLEMENTED] Adding variables - #8 by roman.reiner

So now on your program execution you can do something like this

writer.appendLine("def functionName(): ");
writer.appendLine(“local testVariable == true”);
writer.appendLIne(“return testVariable”);
writer.appendLine(“end”);

So now within the program tree of the UR you can just assign testVariable = functionName(). This method might not be what you’re looking for but there are a lot of issues that can arise from using global variables and using a local variable method with these functions is more secure so operators can not adjust boolean value. Within your URcap you can always adjust this value and set it within the function.