Unable to manipulate URCap generateScript

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, 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!

1 Like