In INTERCONNECT, how to send variables from setup script to global

script
variables

#1

Hello,

I have a compound element, and I want to pass some variables from the setup script of compound element to global. Is there a way to do this?

Thank you,
Zeqin
UBC


#2

Hi @zqlu

Thank you for your posting. If you only have the variables defined in the compound setup script, there is no easy way to read it out. However, I can come up with two work-around, but they are rather inconvenient to implement.

The first way, you can add a result in the “Results” tab and set the variable to this result using the setresult command (remember to check the Annotate box to show this result). Then you can read the result, which is your variable, from the global by using the getresult command.

The second way, if you have another compound/scripted element inside your original compound, you can add a new property to the inner compound/scripted element and set the variable to this property by using the script command set or setnamed. Then you can read out this property by using the scope sign “::” and the script command get or getnamed. This way is rather troublesome and I don’t think it makes much sense to just create an inner compound for this variable; but if you already have one anyway, then I think it is worth trying.

I hope this could help, let me know if you have further problems.

Cheers,
Guanhui


#3

Hi Guanhui,

Very appreciated for your prompt reply.

I tried the first solution and it works well. This is very useful when one wants to do some feedback control in simulation.

best,
Zeqin