how to use string set number of outlets in objects like pack/ unpack/ sel etc.

Wojciech Morawski's icon

Hi!

JavaScript seems to be nice and easy but I've already got first problem :)
I would like to create object (let say unpack) with outlets equal to the specific argument (let say unpack_length). So when unpack_length = 5, unpack with 5 outlets is created.

The problem is - how to put those args in this line of code:
unpack = this.patcher.newdefault(500, 100, "unpack", "unpack_length");

I now how to split a string in js, but got no idea how to put single args in the line of code above.

Any help will be appreciated!

ak's icon

włala:

function make_unpack(unpack_len) {
    var unpack_args = [];
    for (i=0; i < unpack_len; i++) unpack_args[i] = "i";
    this.patcher.newdefault(500, 100, "unpack", unpack_args);
}

Wojciech Morawski's icon

Thank you so much for this solution :) I've send you a prv, check it please!