[widget: script] Get currents value of a widget from JS{{}} with concatenation

We are trying to implement a preset system in OSC.
toggle_preset is a widget the allow/disallow this machine (defined with variables.n) state to be store in preset (defined with variables.p). Preset switch is used to recal presets.

Is there a way in pure-JS to do concatenation of ids ? We tried multiples way to do it and counldn’t succeed to do this.

Example code shown below (not working, syntax error)

JS{{

var toggle_v = @{umc_@{parent.variables.n}_@{parent.variables.p}_toggle_preset.value};
if (@{preset_switch.value} == @{parent.variables.p}) and (toggle_v == 1) {
  set("umc_@{parent.variables.n}_position", @{umc_@{parent.variables.n}_@{parent.variables.p}_position_preset});
} 

}}

There are multiple issues:

  • a bug in open-stage-control that prevents nested @{} calls from resolving in some cases including yours (issue #516)
  • logical operator and is invalid in javascript, you should write && instead
  • "umc_@{parent.variables.n}_position" does not produce the string you want (same problem as in issue #507), you should write “umc_” + @{parent.variables.n} + “_position”

Thanks for your swift reply,
The two last points have been fixed, keep me posted as soon as you want me to test some code to fix #516

The bug is fixed in v0.45.5.