simple input and output

buscon's icon

Hi,

I'm trying to do smt very simple in js inside a max patch: I wanna give three numbers to the javascript, it does a math operation and then prints out the value.

Just in js the code would be:
function r2r(r1,r2,i)
{
int s1 = 1;
int s2 = 127;
newi = (i-s1)*(r2-r1)/(s2-s1)+r1;
return newi;
}

How can I can I do that in js for max msp ?

thanx

Luke Hall's icon

It should be as simple as changing the return to a print() and then sending the object the three numbers you want it to use prepended with the function name, for example "r2r 12 23 5".