Receiving output of JS message to object
Hi everyone,
since I have discovered the use of JS in MAx4Live my life has gotten new meaning! ;)
Thanks to the forum I am learning fast.
I have found out how to send messages to objects in M4L, so I can easily set values or invoke a bang or other things.
However, sometimes an object spits something out after you send it a message, and I would like to capture that in my code:
if I send this 'getslotlist' via a normal message to my autopattr object I get this as a response:

print: slotlist 1 2 3 4
Now if I do this in my code:
this.patcher.getnamed("slots").message("getslotlist");
This gives me the same print output as above (print: slotlist 1 2 3 4)
now when I add:
post(this.patcher.getnamed("slots").message("getslotlist"));
I get this as output:
js: jsobject -1266632561161856
What piece am I missing to get the response with slotlist?
many thanks!
Or should I maybe use pattr?
It's troubling that it has been over four years since Dennis posted this question with no response because I am having a similar problem. I'm trying to get a message object's text (e.g., "32n") with my JavaScript code and all it ever posts to the Max Console is a similar string of numbers.
This code...
tempoResolution = this.patcher.getnamed("tempoResolution");
post ( tempoResolution.getvalueof() );
…only ever produces something like: js: jsobject -1407374883553280
I only ever get a similar string of numbers in the Max Console when I use this code...
tempoResolution = this.patcher.getnamed("tempoResolution").message;
post ( tempoResolution );
How does one use JavaScript to get the current message displaying in a message object?
It seems like this would be a very common thing for people to do and thus clearly described in all the documentation but I can't seem to find it anywhere.
Thanks for any consideration or responses.
based on maxobjlistener example:
inlets = 1;
outlets = 1;
function bang(){
gc(); // Run garbage collection
var obj;
obj = this.patcher.getnamed("t_res");
new MaxobjListener(obj, t_resCallback);}
function t_resCallback(data){
outlet(0, "t_res = " + data.value);
post ("t_res = " + data.value);
post();}
t_resCallback.local = 1;
