Assigning a value from an input to a global variable without passing through SolveInstance/RunScript

Hi all,

My guess is that the answer will be “no”, but let’s ask in case that anyone knows a workaround:

Is there any way of assigning a value from a component input to a global variable (one declarated out of SolveInstance or Runscript) without doing it inside solveinstance/runscript?

My guess is “no, there is not” because the input variables are declared in SolveInstance/RunScript; that said, as the component inputs writes/reference those variables I can guess that there should be other part of the code that could be used to retrieve them.

Thanks in advance.


I think it’s possible. A way would be from a mouse event, for example.
However, you’d have to navigate the inputs manually and go through the PersistentData yourself.

1 Like

Certainly in between any Expire/SolveInstance cycle there won’t be any data in inputs to harvest, so unless the values are stored in PersistentData or come from some obvious object such as a Slider or a Toggle, you’ll have a hard time figuring out what that data is supposed to be.

Since this is such an exotic request, I’d like to know a little bit more about the context. What problem are you trying to solve?


Thanks @piac and @DavidRutten for the fast reply.

To be honest I fixed the thing without needing this exotic solution. I was coding a dynamic counter that reads some values from some inputs. As the counter needs to keep track and consistency out of SolveInstance to work properly (the objects controlling the behaviour will be declared out of it) but at the same time I need to read certain inputs that the user provide, my first idea was trying to read inputs out of SolveInstance under specific events without writing those values in my “global variables” at every SolveInstance tick.

I manage to do it without this approach but I thought that could be interesting to know if there is any way to do it, in case that other problem that could require it can appear in the future…and that is because we are talking.