Forums > Javascript

javascript question

March 14, 2011 | 2:55 pm

Hi,

This is supposed to work like a swap objcet,
why does not inlet 0 (an integer) go to outlet 1?

inlets = 2;
outlets = 2;

function msg_int(a)
{
if (inlet == 0)
outlet(1, a);
}

function msg_int(b)
{
if (inlet == 1)
outlet(0, b);
}

is msg_int a method of function here with a and b as parameters?

Thanks



MIB
March 14, 2011 | 6:08 pm

try this:

inlets = 2;
outlets = 2;

function msg_int(a)
{
if (inlet == 0)
outlet(1, a);

else if (inlet == 1)
outlet(0, a);
}


March 14, 2011 | 10:49 pm

You can only have one msg_int() function per javascript. As MIB explained above with his example you need to query the inlet to work out how you will separate any functionality.


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