access data from a different subpatcher?
Thanks, I was hoping such a thing was possible. From the tutorial on globals, I got the impression they were only good for sending messages between patchers, not accessing variables. Could you provide an example of how to, for example, declare a global array, and then access it?
If I remember correctly you just would declare your array without the var prefix in one script, then access it by name in the other.
foo = new Array;
var localVar = foo[x];
Wow – well that’s pretty cool. Wish I’d known about that a while ago :-) Thanks for the help Jesse!
I would recommend going the Global object route. it’s the cleanest way. Omitting the var keyword is more like a hack.
What ej means is of course: create one unique object with the name of your project and use its properties. All globals are dangerous, but one is better than many.
Agreed that it’s cleaner to create a single global object and set/get its properties in all scripts. But it’s still useful to know the implications of the var keyword within functions.
http://www.cycling74.com/docs/max5/vignettes/js/jsglobal.html instead of http://www.cycling74.com/docs/max5/vignettes/js/jsglobalobject.html.
That explains why I never heard about it ;)