Forums > Javascript

outputting a js object into a function

August 13, 2012 | 7:47 am

Hi,

I want my javascript code to build an X,Y description for a function’s input. However I can’t seem to find a format that the function will recieve. The only format the function reacts to is if i give only one argument i.e single X and a single Y inside a list.

This is a problem for me and the funny thing is you can do it no problem with a message. The format with a message is: "x0 y0, x1 y1, x2 y2 etc..". Needless to say the same line would now work once oulet from a js script.

Thanks in advance,
Elad.


August 13, 2012 | 2:46 pm

It shouldn’t be a problem. Just send multiple two-item lists in immediate succession. (That’s what a message with commas such as "x0 y0, x1 y1, x2 y2" is doing.)

function draw()
{
outlet(0, "clear");
outlet(0, "setdomain", 1);
outlet(0, 0., 0.);
outlet(0, 0.1, 1.);
outlet(0, 0.3, 0.5);
outlet(0, 0.8, 0.4);
outlet(0, 1., 0.);
}


August 13, 2012 | 5:58 pm

that’s possible although it complicates a lot of things for me. It would be amazing if I could just send out the list. Perhaps there is a max object (not JS) that can break down the list for me?


August 13, 2012 | 8:17 pm

Yes. See the zl object ("zl iter 2" or "zl group 2"). But beware of odd numbers of items in your lists. (You can use the "zlclear" message to zl group 2 to protect against that.)

– Pasted Max Patch, click to expand. –

Viewing 4 posts - 1 through 4 (of 4 total)