Pass variable values between C# variable and widget variable

I’m working on a project that I want to use some C# code and some widgets. I will need to pass variable values back and forth between the widgets and C# code. Is there a simple way to do this? Thanks!

Yes. When you define variables there on the first tab, they are available in code and widgets.

Perfect. Thanks!

This didn’t work as I had hoped. Here’s my setup. I’ve got the variables defined in the function.

In my C# code I set those variables and I write those variables into the application log.

Then I have a widget to display those variables -
image

When this function runs, the log shows that the variables have the correct valued, but the Message that pops up does not have any of the values. Have I missed something?

I believe by redeclaring the variables in your code; you’ve scoped over the ones you defined in the tab. Remove the leading “string” in front of your assignments. In the code block, you should be able to right-click and insert the variable for use. There’s no need to declare them again.