Forums > Javascript

get comment or message box content within a js ?

Aug 21 2010 | 9:01 am

I would need to get (and set) the content of (named) comment and message box within a js.
is it possible ?
couldn’t find info about it in the doc.
any help is very welcome !

thanks in advance


Aug 22 2010 | 3:47 pm

Setting is as easy as sending a message to the named object with the set or message functions, but retrieving the current information is much more difficult. One idea is to script a [grab] object into place and connect it to a [message] box and back to a dedicated inlet of your [js] object. If you only need this to work in a patching environment you can even parse the JSON text of your patch as demonstrated in this article. However this won’t work with anything other than a maxpat file so if you need it to function in a standalone application this method will not work.

Aug 24 2010 | 8:11 am

Thanks Luke for your reply.
unfortunately, this won’t help me much, because i need to get the content of a comment box, and grab can’t get it ; (and my js isn’t in the same patch…)
ok, I’ll find a workaround !

thanks !


Sep 02 2010 | 8:56 am

I think you might ask C74 directly, and they should really adapt a bit max objects to your goals in next incremental max version, come on!, what you’re working on ( ) is just the future of max!

Sep 13 2013 | 12:30 pm

Mathieu, did you ever resolve this issue? I am trying to do something similar, retrieving the text of a comment box with JS. Any info of your process or solution would be appreciated!

Sep 14 2013 | 2:15 am

no, sorry, I never found a solution, and finally had to give up retrieving content of comment box.


Sep 14 2013 | 8:38 am

One way to do this is to load up the patcher as JSON and then parse it for comment boxes.

Please excuse the roughly hacked out code – hopefully you will get the idea

var patcher_file = new File(this.patcher.filepath);
while (patcher_file.position != patcher_file.eof)
lines += patcher_file.readline();
var parsed_patcher = JSON.parse(lines);
if (parsed_patcher["patcher"]["boxes"][0]["box"]["maxclass"] === "comment")

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

Forums > Javascript