script object in parent patcher...

    Mar 21 2011 | 10:01 pm
    I'm not sure this is possible (well, maybe with js) but here it goes anyway:
    I have an abstraction that is used for debugging purposes only. whenever it is created, I would like to have a message box scripted and connected to the rightmost outlet of the abstraction. I don't think thispatcher will be of much help since that only works on the same level the object is in. I need to script the new object in the PARENT.
    Any ideas? Thanks

    • Mar 22 2011 | 12:52 am
      Is there no way you could load this abstraction into a [bpatcher] so you can leave the message box inside the abstraction and have it clickable from the parent patcher without having to worry about extra scripting?
    • Mar 22 2011 | 4:50 am
      it's not impossible, but since it's for debugging only it's less of a hassle if it's an abstraction. It's really not a big deal to add a message box manually, just wondering if there was a way to automate it... always trying to improve things ;)
    • Mar 22 2011 | 6:12 am
      Try something like the code below. You might have to change the spacing values but these work fine on my current set up. It assumes your object has 3 inlets. I'm not quite sure how you'd get it to fire when you instantiated the abstraction though.
      function bang() {
          p = this.patcher.parentpatcher;
          if (p) {
              b =;
              loc = b.rect;
              a = p.newdefault(loc[2]-19,loc[1]-20,"message");
              a.set("this is the text");
          } else {
    • Mar 22 2011 | 6:14 am
      have been playing with the js object a bit and seems to be working fine. haven't done any extensive testing yet (it's rather late).
      /*************save js as parentTest.js***********************/
      function bang() {
      var parent = this.patcher.parentpatcher;
      var objCoords=;
      var a = parent.newobject("message", objCoords[2] - 19, objCoords[3] + 5, 70, 16);
      parent.connect(, 2, a, 0);
    • Mar 22 2011 | 6:15 am
      seems like you just beat me to it ;)
    • Mar 22 2011 | 6:18 am
      to get it to fire I use a patcherargs -> [sel done]. seems to work for now. again, have to do serious testing tomorrow. for now I'm happy and will get some sleep!!!
    • Mar 22 2011 | 11:21 am
      Great idea! I'm sure there's a way to force the object width if you're adding text to the message box too. It can be done with @fixwidth 1 using [thispatcher] so I image you can achieve the same thing in javascript too somehow.