Forums > MaxMSP

JavaScript and Dict

January 8, 2014 | 9:39 am

Hi there

I am wondering if anyone can give me a simple example of how I can get data from a dictionary into a Js object to work with it

Lets say a function that takes each key and posts its data to the max "terminal"

January 9, 2014 | 9:22 am

You can use getkeys() and get(). I attached an example!

  1. keys_from_dict.js

January 9, 2014 | 11:46 am

Thanks a lot :)

February 9, 2014 | 4:25 pm

Hi again

I am wondering where the ‘get’ in: d.get(keys[i]
… is coming from ?

I am trying to find a way to throw the whole value list of the d object out of the 0 output of the max js object , but I only get one set of numbers (the last one, out of 200)

var d = new Dict("funkyDict");

function post_to_max(){
var keys = d.getkeys();
for(var i = 0; i < keys.length; i++){
post(d.get(keys[i]), "\n"); // This will post the value
outlet(0, d.get(keys[i])); // This will post the value

February 26, 2014 | 9:20 am

This is all very nice, get and set. But is there any way to make max Dicts into first class objects in javascript.

If you are aware of json use in web/javascript. There is no need for gets and setters, because JSON is the syntax of javascript objects.


var me = {"username" : "furiousgreenloud", age : 41"};

means you can use your me.username, DIRECTLY in your javascript, plus all the iteration and the rest of the language is just there!

I would expect a new Dict("me") to return an actual javascript associative array (which is an object), or as least, there to be a new Dict("me").obj() method. Or at very least new Dict.borrow("me") and then new Dict.return("me") methods?!!

much love & respect.

June 13, 2014 | 6:59 am

Hi Furious, did you come across my wiki post?

Viewing 6 posts - 1 through 6 (of 6 total)