Inc/Dec value of max object in javascript?

    May 02 2016 | 10:50 am
    This one might be a little is getting more and more rare these days when I find something that trips me up.
    I have this nifty little "MIDI Learn" tool that allows you to click on UI elements in your Max patch and assign MIDI controllers to these objects dynamically.
    Here is a link to the midilearn Tool - with access to the source code:
    The problem I am currently trying to solve is that one of my controllers has a knob - which you can turn - however, it doesn't send MIDI CC values as you would expect - it sends a value of 127 for every click of turning clockwise, and value of 0 for every click of turning counterclockwise.
    So what I need to do is whenever one of these types of MIDI controls is assigned to a UI element, I need to increment/decrement the current value based on a MIDI CC value of 127/0. This should be easy...
    Here is the problem. I don't know how to query the current value of an object from javascript.
    So lets say I have already acquired a javascript reference to my UI object and assigned it to a var : obj. I can do things like:
    var obj = this.patcher.getnamed(nameofobj);
    var thisPatcher = obj.patcher; // this works just fine
    if (obj.understands("rawfloat")) {
      obj.message("rawfloat", newval / 127.0);  // this works just fine
    What I want to do is something like:
    if (control == incdecTypeControl)
     if (ctlValue == 0) {
         obj.value -= 1;    // or whatever value I have determined is the incremental value
        // you can't do this because there is no "value" parameter for a max object - which is kinda absurd
    else if (ctlValue == 127)  {
        obj.value += 1;  // there is no obj.value - so how do I increment the value?

    • May 02 2016 | 2:33 pm
      if i follow you correctly - you want to be able to get the value of a dial and increment it?
      if so -
      var currVal = obj.getvalueof(); obj.setvalueof (currVal++);
    • May 02 2016 | 7:33 pm
      Ahh... they are methods on the obj - not properties... This seems to work just fine... any idea where in the docs these get/set methods (obj.getvalueof() / obj.setvalueof() ) are documented? Are these officially supported methods?
      Thanks a bunch!
    • May 02 2016 | 7:51 pm
      great - glad that helped.
      definitely officially supported: