How to retreive data from max send objects (aka receive inside JS)recev

Feb 2, 2009 at 7:22pm

How to retreive data from max send objects (aka receive inside JS)recev


I’m fine with sending data from JS to max land (using messnamed) but how to do the other way around ?
How to receive inside JS data that are sent from my max patch through ‘send’ object ?

Thanks for any help,


Feb 17, 2009 at 8:23am

Anyone ?


Feb 17, 2009 at 11:13am

It could be done by writing a javascript that uses global functions. You could replace your [send]s with a js that stores a global that you can use in your other js and that also uses the messnamed thing to act as a regular [send]. I’m about to head to work but if you want I’ll put something together this evening and post it here.


Aug 31, 2011 at 11:19pm

It’s been a while since this post, but I’m curious: how do you declare global functions in js? could you post a simple example of how to communicate two javascripts?
thanks in advance!

Sep 1, 2011 at 1:32am

Try sticking a js object in a patch and get help on it . . ..
It will tell you “For more info about the js object, pease consult the Javascript in Max documentation, and the various examples located in ./examples/javascript. “
In these you will find what you need to know, there is even a globalvar example patch . . .

Sep 1, 2011 at 9:14am

Here’s some code that will work like a simple version of the [value] object, the only difference being that you don’t set a name for the object, every instance will be linked.

glob = new Global("uniquename");

function anything() {
    glob.tosend = arrayfromargs(messagename, arguments);

function bang() {
Sep 1, 2011 at 4:57pm

Umm… how about hooking up a [receive] object to one of your [js] inlets?

It has the advantage that you can double-click on the [send] and the recipient will be in the popup menu. Big help for debugging.

Sep 1, 2011 at 7:43pm

Thanks for the answers
@Macciza I did know a little bit about the global variables, but I thought that they were “variables”, not functions, that´s the reason why I asked. But surely I missed something in the documentation, I’m quite new with js and scripting in general.

I’ll check out Luke’s example

– Pasted Max Patch, click to expand. –

//js file code.js

inlets =1;

function printHello() {
outlet(0, “hello”);


//end js file

Oct 1, 2011 at 3:04pm

BTW: in javascript, you can assign a variable to contain a function. This is occasionally useful when, for instance, you want to determine which function you want to use on the fly. see for example.


You must be logged in to reply to this topic.