Strange pattr behavior with JS


    Jul 27 2010 | 9:38 pm
    I'm struggling with strange pattr behavior. It seems to me that it is common for both JS and visual environment. I use pattr to store param value between sessions. I need pattr to load param and trigger JS init method. If param is equal to 0 (it wasn't initialized earlier) then its value is initialized and saved to pattr. Otherwise pattr value is used As you can see, pattr triggers initVar method, but method fails to set pattr new value. When bang triggers initVar then all is fine What can it be? A sort of loopback protection?
    test2.js
    autowatch = 1;
    inlets = 1;
    outlets = 1;
    
    var data;
    
    function initVar(variable) {
    	data = parseInt(variable);
    	if (data == 0) {
    		data = 30;
    		post("data " + data);
    		this.patcher.getnamed('store_var').message(data);
    	}
    }

    • Jul 27 2010 | 10:56 pm
      Yeah, I imagine there could be a feedback problem there.
      This works.
    • Jul 28 2010 | 12:22 pm
      Awesome, thank you!