output to outlet arrays stored in array


    Oct 08 2012 | 6:44 pm
    If I feed the below js the message "4AB" "next step" I'd like to get 'definitely 4,"no way" 5,"possibly 6' out of the js object's outlet. Instead I getjsobject 494128416 jsobject 494128472 jsobject 494128528
    will I have to store those sub-arrays as symbols to get my desired results?? I'd rather not! This seems like it should be simple, but crossing the JS/Max barrier is proving tricky! I tried something similar with the dict object, but I get"4AB::next step" What am I missing?? Peter.
    /* retrieve arrays from a JS object heirarchy*/
    var ctls={
    	"4AB" : 	{
    		"4 sounds" : [ [ "yes",1 ], [ "no",2 ], [ "maybe",3 ] ],
    		"next step" : [ [ "definitely",4 ], [ "no way",5 ], [ "possibly",6 ] ]
    	}
    ,
    	"16B" : 	{
    		"16 presets" : [ [ "A" ], ["B"], [ "C" ] ],
    		"step enables" : [ [ "D" ], [ "E" ], [ "F" ] ]
    	}
    }
    
    function anything(){
    	var v=arrayfromargs(messagename,arguments);
    	post("n?",v[0],v[1]);
    	outlet(0,ctls[v[0]][v[1]]);
    }
    

    • Oct 24 2012 | 9:22 am
      does this work? v[0].toString()
      outlet( 0, ctls[ v[0].toString() ][ v[1].toString() ] );