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
    Mathieu

    • 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 !
      Mathieu
    • 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 ( https://cycling74.com/forums/sharing-is-fantastick-max-multitouch-framework-for-fantastick-ipad-iphone ) is just the future of max!
    • Sep 13 2013 | 7: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 | 9:15 am
      no, sorry, I never found a solution, and finally had to give up retrieving content of comment box. :-(
      M
    • Sep 14 2013 | 3:38 pm
      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(); } patcher_file.close(); var parsed_patcher = JSON.parse(lines); if (parsed_patcher["patcher"]["boxes"][0]["box"]["maxclass"] === "comment") { post(parsed_patcher["patcher"]["boxes"][0]["box"]["text"]);post(); }