Getting and Setting variable values

Setting variables from outside

Enter text to change variable value:

We listen to changes in the input field and set a variable then:

document.getElementById("myInput").addEventListener("input", // listen to input events from our input field element
(e)=>
{
    CABLES.patch.setVarValue("myStringVar", e.target.value); // set the value of our variable when input has changed
});
    


Reacting from variables changes inside the patch

In our patch mouse coordinates are set to variables "mousePosX" and "mousePosY"
When those variable changes we want to receive the values and display them:

/

move your mouse over canvas to see changes.

const vy=CABLES.patch.getVar("mousePosY"); // get the variable object
vy.addListener( // add a listener, which will be calles everytime the value changes
    (v)=>
    {
        document.getElementById("mousePosEleY").innerHTML=v; // update html with new value
    });

    


open original patch