Access local variable from another button
Is this a feature relevant to companion itself, and not a specific module?
- [x] I believe this to be a feature for companion, and is not specific to a module
Is there an existing issue for this?
- [x] I have searched for similiar existing issues
Describe the feature
Currently it is possible to set another button's local variable using the action internal: Local Variable: Set with expression, but I see no corresponding way to get the value of another button's local variable.
A "very" simple change would be to add to the variable syntax something like $(_page_/_row_/_col_:x)? As best as I can tell without looking at the code, the syntax should be ok...
Alternatively: add a local-variable "feedback" that sets a new local variable to the value of another button's local variable.
Usecases
Use case (taken from Dan Soethe's FB post):
Make a rotary encoder set a local variable incrementally, i.e. $local:x) = $(local:x) +/- 1, and then display the value on the corresponding button (think SD+ and knobs and LCD-strip).
You can do it now by having the encoder set the value in the LCD button, but it seems to me more natural (client-server-ish) to have the variable stored in the encoder and any other button that wants to access it can do so.
This is not trivial to achieve (in the current architecture), in particular I am worried about the performance cost of throwing even more variables into the global pool. In the current system, whenever a variable changes we are telling various places 'these variables changed', as we arent tracking what is used where.
I dont 100% remember, but I think it was intentional to not expose the local variables outside of a control. I think the only reason it is possible to set one externally is because it was simple to implement
Perhaps another option is to be able to reference $(target:abc) inside the Local Variable: Set with expression action?