Script File in a Program Node

Hello,

I am currently working on building a URCap and i have set of functions done in a script file. I would like to call the script file in one command and not write all my script lines in the program node generateScript section. Is there a way where i can call a script file?

I tried writer.appendLine(“Program_1()”); in the ProgramNode and the Program_1.script was saved in the root folder. And when i did this, it gave a compilor error saying Program_1 was not defined.

Any help on this? Thanks,

Take a look at this sample: URCap Sample: Script Wrapper URCap

Hello @sko,

Thank you for the reply. But this example is in a HTML. I would like to have one in Swing. Is there any?

Thanks,

Hi @vineeth1,

Dispite the fact that the sample listed above is for a HTML based URCap, the code that writes an entire script fileis still sound. Have a look at his generateScript() method at the bottom of the contribution file. You will see that it contains just one method which locates the script file in the file system (you can either locate the script file ni the robots file system or, if the script file will never change, bundle it in as part of your URCap) The rest of the method then converts the script file intoa long string that can be written with one line of writer.appendLine().

Hope this helps

1 Like

Hi @sam.verity-hilton

Thank you for the reply. It worked.

2 Likes

Glad to hear its worked! Happy to help :slight_smile:

1 Like