Forums > Javascript

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

Feb 02 2009 | 7:22 pm


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 | 8:23 am

Anyone ?


Feb 17 2009 | 11:13 am

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 | 11:19 pm

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 01 2011 | 1:32 am

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 01 2011 | 9:14 am

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 01 2011 | 4:57 pm

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 01 2011 | 7:43 pm

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 01 2011 | 3:04 pm

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.

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

Forums > Javascript