Beginners question about scripting


    Dec 27 2015 | 12:58 am
    Hi
    Im really new to Javascript and i feel this is probably an obvious one. Im just trying to add a few number boxes to a patch and establish patch cord connections. I can add the boxes okay but cannot make the connections. Ive looked at the example patches and searched a few videos and as far as I can tell the syntax here is correct - although its clearly not :) - so any help would be hugely appreciated.
    Cheers
    var a; var p = this.patcher; var number = new Array(3); function bang() { if (a = p.getnamed("number1")); p.remove(a); if (a = p.getnamed("number2")); p.remove(a); for (var i = 0; i < 3; i++) { a = p.newdefault(300 + (i*30), 120+ (i*30),"number"); a.varname = "number[i]";
    p.connect(number[1], 0, number[2], 0); //error message saying number1 is not defined } }

    • Jan 14 2016 | 11:41 am
      Move the closing brace 2 lines from the bottom ABOVE p.connect (and of course an array index starts from 0 so number[0] is the first one)