send message without patchcord and without using fromsymbol


    Apr 20 2022 | 10:45 am
    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!

    • Apr 20 2022 | 11:49 am
      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.
    • Apr 20 2022 | 11:56 am
      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.
    • Apr 20 2022 | 7:25 pm
      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.
    • Apr 20 2022 | 11:07 pm
      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)
    • Apr 21 2022 | 3:08 pm
      @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?
    • Apr 21 2022 | 3:48 pm
      check the docs for Maxobj and Patcher objects in JS. Maxobj has a subpatcher() function.
    • Apr 21 2022 | 7:51 pm
      thx pretty obvious :) this.patcher.getnamed("1stlevel_patcher").subpatcher().getnamed("2ndlevel_patcher").subpatcher().getnamed("myobject").set(myval);