conditional operetions in javascript


    Oct 14 2012 | 5:50 pm
    Hi everyone,
    sorry for my basic questions but I'm really new to javascript.
    Can anybody make me a "js object" with several inlets and outlets with wich I can do several conditional operations?
    I basically need something like an "if object" but in java wich should allow me to do more complex conditional operations.
    Thank you!

    • Oct 14 2012 | 5:56 pm
      ...the js object should actually be able also to read lists
    • Oct 14 2012 | 8:21 pm
      I think this page is a very good start for what you want to accomplish: https://cycling74.com/docs/max5/vignettes/js/jsbasic.html
      to give you a quick example, below are two functions, one accepting a list, the other listening for int on the inlets, simply adding those values. from this point on it should be easy to implement any sort of list/number operations.
      inlets = 4;
      outlets = 1;
      
      var val1 = 0;
      var val2 = 0;
      var val3 = 0;
      
      function list(val) {
      
      	var sum = 0;
      	for(var i in arguments) {
      	   sum = sum + parseInt(i);
      	}
      
      	outlet(0, sum);
      }
      
      function msg_int(val) {
      	if(inlet == 0) {
      	  outlet(0, val + val1 + val2 + val3);
      	}
      	else if(inlet == 1) {
      	  val1 = val;
      	}
      	else if(inlet == 2) {
      	  val2 = val;
      	}
      	else if(inlet == 3) {
      	  val3 = val;
      	}
      }
      
    • Oct 15 2012 | 4:34 pm
      Hi,
      thanks!
      How do I have to write this in JAVA:
      if $i1 == 0 && $i1 < $i2 && $i1 < $i3 then 1 else out2 $i2
      thanks!