accessing multiple inlets from js object


    Nov 28 2006 | 8:57 pm
    sorry if i missed somehting completely obvious but i need to assign each input on my js object to a different variable in the javascript file. so far any input i use changes on the "throttle" variable and the inlet() function gives an error that it does not exitist, any help would be incredibaly apreciated.
    follows are the patcher and javascript
    ----------------------------------
    --------------------------------
    var throttle = 0; var cutoff = 6500; var rpm = 1000; var ratio = 3.45; var fd = 3.94; var load = 0; var speed = 0; var dragco = 0.31; var drag = 0; var tire_w = 195; var tire_s = 45; var rim = 15; var pi = 3.14159; var acc = 0;
    function msg_int(throttle) { speed_cal(tire_w,tire_s,rim,fd,ratio,rpm); drag_co(dragco); acceleration(); outlet (0, throttle); }
    function speed_cal(tire_w,tire_s,rim,fd,ratio,rpm) { speed=(tire_s*tire_w/100+rim*25.4/2)*2*pi*rpm*60/(fd*ratio*1000000); outlet (1, speed); }
    function drag_co(dragco) { drag = speed * dragco; // outlet (0, drag); }
    function acceleration() { acc = power() - drag; // outlet (0, acc); }
    function power() { if(rpm < cutoff) load = Math.sqrt(rpm) * throttle; else load = Math.sqrt(rpm); outlet (2, load); }

    • Nov 29 2006 | 7:35 am
      inlets can be accessed as a property of the jsthis object, see the JavascriptInMax.pdf page 14.
      in the script you access it like so:
      if(this.inlet == 0) for the leftmost inlet
      or with a switch statement for a more elegant routing structure
      switch(this.inlet){ case 0: case 1: etc. }
      hth
      /*j
      > sorry if i missed somehting completely obvious but i need to assign > each input on my js object to a different variable in the > javascript file. so far any input i use changes on the "throttle" > variable and the inlet() function gives an error that it does not > exitist, any help would be incredibaly apreciated.