send message without patchcord and without using fromsymbol

fraction's icon

Hi,
i d like to send a message from within a js code using

this.patcher.getnamed("myobject").message(mymessage);

my final object is an osc formated like object expecting input message as: /myparam value1

js sends its message with quote marks: "/myparam value1" which is ofc not recognized by my destination

Normally in with max objects, you would just put a fromsymbol at the outlet to correct the message, but as i would like to not use a patchcord/outlet, what would be the way, if there is one, to send the message directly as it is to that object, so without the quote marks?

thx!

Andy Maskell's icon

You can give Max objects a scripting name in the Inspector and use things like pattrforward to route messages directly to them without a patch cord or using send/receive. Whether that would also work from within JS I don't know.

fraction's icon

well, that wasn't my question. For your information, the method this.patcher.getnamed("myobject") implies that obviously a scripting name "myobject" has been given.

11OLSEN's icon

How do you set "mymessage" ? Is it an array or a string? I think you can also use .message() like this:
this.patcher.getnamed("myobject").message(item1, item2); but haven't tried now.



tyler mazaika's icon

In case you didn't know (and assuming its useful for OSC communications), you can also try doing arbitrary length argument lists doing something like this for more flexibility:

var maxobj = this.patcher.getnamed("myobject")
var args = ["/myparam", "value1", "valueN"]
maxobj.message.apply(maxobj, args)

fraction's icon

@tyler - thx this seems to work.

would someone know the syntax if you want to send a message (just a simple var value), to an abstraction/bpatcher but that is bellow the main patcher where is the js code?

with pattr we would use parent :: - is there's somekind of equivalent in js?

tyler mazaika's icon

check the docs for Maxobj and Patcher objects in JS. Maxobj has a subpatcher() function.

fraction's icon

thx pretty obvious :)
this.patcher.getnamed("1stlevel_patcher").subpatcher().getnamed("2ndlevel_patcher").subpatcher().getnamed("myobject").set(myval);