Universal Robots Forum

URCap for calling URscript

I am working on URcap project. I have prepare a code in URScript. The following URScript is of 200 lines. I want to write a script in generate script() function. Is there any way that I can directly call a function for URscript instrad of writting 200 line code.

You could place your 200 lines of script code in a file in your resources folder.
Then read this file, and use the ScriptWriter appendRaw() method.

Thanks Jacob. So the appendRaw() will able to compile full URScript.
Is this a correct way to do it.
@Override
public void generateScript(ScriptWriter writer) {
writer.appendRaw("home/rohan/Documents/URDevelopment/URCap/resources/impl/temp.script");

According to the Javadoc, the appendRaw() method will append the raw script to the ScriptWriter, without auto-indentation and similar. This means you can import this from i.e. a file which has indentation and so on.

Unfortunately, the approach is not just quite as easy, as you suggest above.
You need to open and read the file. I suggest you take a look at this sample: