# Unable to manipulate URCap generateScript

**URL:** <https://forum.universal-robots.com/t/unable-to-manipulate-urcap-generatescript/23098>\
**Category:** URCaps SDK\
**Created:** [August 4, 2022, 9:55am UTC](https://forum.universal-robots.com/t/unable-to-manipulate-urcap-generatescript/23098 "2022-08-04T09:55:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon34306213](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@anon34306213](https://forum.universal-robots.com/u/anon34306213)\
**Post date:** [August 4, 2022, 9:55am UTC](https://forum.universal-robots.com/t/unable-to-manipulate-urcap-generatescript/23098/1 "2022-08-04T09:55:36Z")

</div>

Hello,  
I am trying to create an URCap where user inserted nodes are executed multiple times to avoid many repetitions of slightly different actions.

I am almost completely done, except for the part where the action themselves are written as URScript code during the `generateScript` function in the `ProgramNodeContribution`.

Here are the problems:

- Because I do not know the Nodes that the user will insert, I **cannot** write the URScript manually, it must be done programmatically.
- To be done programmatically, the easiest way that i found (And if someone has a better way I will gladly listen) is to use the `writeChildren()` function and letting the users insert the desired nodes as children of the URCap node.
- Because I need to repeat the writing procedure, I must call the function multiple times, receiving in return the error message **Compile error: Duplicate label** , meaning that this function should probably not be used more than once.
- I have seen [This forum post](https://forum.universal-robots.com/t/are-program-labels-essential/12052), which gave me the insight that label **can be removed**. However that poster had already at their disposal the desired script to read, which I do not have.
- I have searched for the `writeChildren()` implementation but only found the interface declaration, meaning that I would not be able to either edit nor override the function’s implementation (Writing it myself from scratch would be a sure way to make a mess).
- Furthermore, it would be trivial, since labels are always of the format “$ N” where N is a number, to read a URScript file and edit it on the fly so that the URCap could read and execute it as needed without the duplication error.
- However, again, because I cannot see the implementation of `writeChildren()` I cannot figure a way to hijack the function on a temporary file.

So there’s that, I suppose my questions are:

1. Is it possible to use `writeChildren()` so that no label gets duplicated?
2. Is it possible to read the `writeChildren()` implementation somewhere?
3. Is it possible to hijack `writeChildren()` to write on a temporary file instead of the URCap node logic?

Thanks and any help appreciated!
