JavaScript and Dict

Jan 8, 2014 at 9:39am

JavaScript and Dict

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”

#277745
Jan 9, 2014 at 9:22am

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

Attachments:
  1. keys_from_dict.js
#277831
Jan 9, 2014 at 11:46am

Thanks a lot :)

#277842
Feb 9, 2014 at 4:25pm

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
}
}

#280530
Feb 26, 2014 at 9:20am

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.

so

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.

#282155

You must be logged in to reply to this topic.