4.63 - passing js inlet to outlet

jayrope's icon

hello there, i am a newbie in this section of max and have a very stupid question:

how would you pass thru a constant data flow from an inlet 0 of a js object to outlet 0?

i can't find the right syntax for the according line in the javascript.

tried
outlet(0, inlet(0));
as part of a function bang(), which gets banged each time i want to pass the data value thru. that doesn't work.

any help very appreciated. also i would appreciate any tutorial or reference hints you could give me for js operation in general.
i have gone thru all max 4.63 tutorials already, but a reference for available js syntax to reference objects is missing there completely.

thank you very much in advance!

jrp

gusanomaxlist's icon

Hi.
Assuming you wanna pass numbers through:

function msg_float(x) {
outlet(0, x);
}

function bang() will be triggered only when a bang is sent to js.

I'm sure you can find "JavascriptInMax.pdf" somewhere on the website (maybe with the 4.63 doc?).

HTH

Ciao

jayrope's icon

oh my. i'm very sorry, had overlooked the pdf buried in sub sub sub folders.

thank you very much!

jrp

jayrope's icon

I'm sorry to bug you again, gusanomaxlist.

what do i put into x, when running your function? i can see that it mentions outlet 0, but how will i make sure its inlet 0 passt into it? do i just run
msg_float(0) on a permanent base?

thank you very much again!
i'm certainly not a javascript newbie, but this is too abstract for me right now...

jrp

gusanomaxlist's icon

function msg_float() is a special function (I guess) triggered each time
a number (float or int) is sent to any inlet of js.

Another example that might give you some ideas: Let's say that you wanna
pass numbers only under a certain condition, then you could say:
"I'm gonna use a function that will pass through the numbers":

function pass(x) {
outlet(0, x);
}

and call it in from patch like that:

number
|
[pass $1(
|
js

I advice you to read the tutorial I mentioned earlier, it's gonna be
very helpful ;)

Ciao

dalinnen's icon

the function msg_float is called whenever a float reaches an inlet of your js object. the 'x' as in....

function msg_float(x) {....

is just defining the input as variable x within your function. you could just as easily have....

function msg_float(rad) {.....

and then any input from this function would be accessible as the variable rad.

if you want to get only floats from the first inlet, you could check the reserved property 'inlet' and do something like this....

function msg_float(x) {
if (inlet == 0) {
outlet(0, x);
}
}

hopefully that is all correct and helps. take care.

--dave

jayrope's icon

thanx you two very much, your hints work well, reading the tutorial furthermore.

jrp