Javascript Bug


    Oct 29 2008 | 12:19 am
    I believe I have discovered a javascript bug. This bug has been discussed and confirmed in another thread on this forum, and I also email support about it, but there hasn't been any response from c74 confirming the bug. Below is the description:
    To demonstrate the bug: I have used a javascript to create a bpatcher object, assign a patch to it, set its presentation mode, and set its presentation size and location. I have done this successfully using the following code:
    function bang() { var a = patcher.newobject("bpatcher"); a.presentation(1); a.presentation_rect(100,100,800,800); a.replace("bpatch prototype.maxpat"); }
    However, if I rearrange the order of the commands, I get an unexpected error. If the "replace" method is called before the "presentation_rect" method is called, as in the following example:
    function bang() { var a = patcher.newobject("bpatcher"); a.presentation(1); a.replace("bpatch prototype.maxpat"); a.presentation_rect(100,100,800,800); }
    then the following error shows up in the Max window:
    Object Message patcher doesn't understand "presentation_rect"
    At one point, I also got an error of "js: test.js: Javascript TypeError: a.presentation_rect is not a function, line 11" but I can't figure out how to reproduce that error at the moment.
    Is there any reason why I shouldn't be able to set the presentation_rect after a replace command has been issued, or is this a bug?

    • Nov 01 2008 | 11:46 am
      This bug is really affecting the development of my patch right now... My patch needs to create a bpatcher and load a patch into it, and then at a much later time it needs to move the bpatchers around. This bug prevents me from moving the bpatchers around after a patch has been loaded into them.
      Can anyone at c74 at least confirm this bug and let me know that it's on your radar? ... and that you're hopefully working on it for the next incremental?
      Thanks
    • Nov 01 2008 | 11:48 am
      Sorry, just realized I forgot to mention OS and Max version in the original post. I'm using:
      OS 10.5.5 Max 5.0.5
    • Nov 03 2008 | 12:53 am
      I've been informed by c74 that this bug is not going to be a simple easy fix, and therefore might take awhile. However, below is a workaround that worked perfectly for me:
      var id = 103812; //could be any random number
      function bang() { var a = patcher.newobject("bpatcher"); a.varname = "ID-" + id++; a.presentation(1); a.replace("bpprototype.maxpat"); this.patcher.message("script", "sendbox", a.varname, "presentation_rect", 100, 100, 800, 800); }
      Basically you're telling the patcher to move the bpatcher object instead of telling the object to move itself.
    • Nov 12 2008 | 9:56 am
      Scott schrieb: > However, below is a workaround that worked perfectly for me:
      This looks more like a solution than a workaround to me... Its hard to grab, but once you know the difference, its easy... And hey, lines of code sort of programming needs smart coders anyway...
      Stefan
      -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com