Unable to set variables from outside cables

Setting a variable externally using
gives me a variable not found error.

If I try getting the variable object with
var myVar = CABLES.patch.getVar(“variableName”)
myVar is undefined.

From within cables, running
from the console does return the variable I am looking for.

Is there any workaround to be able to set variables externally?

Try following this procedure:

On cables:

  • Ad the ‘SetVariable’ OP to the patch and, on the input pannel, create a new variable name. [+ create new one]
  • Ad the ‘Variable’ OP to the patch and, on the input pannel, select the variable you created before on the dropdown list.

On the script (or terminal):

  • To set variable: CABLES.patch.setVarValue(‘myvarname’, value);
  • To read variable: CABLES.patch.getVarValue(‘myvarname’);

Good luck.

1 Like

That worked! Thanks!

in the next update there will be a way to set variables already in the patch constructor, which makes it way easuer

Could also be good to have one single Op to set and get variables?
Kind of how the ‘Value’ Op works but setting a variable instead.