Once in a while… Or: A wish for the future: console.log()

Mar 11, 2011 at 12:11am

Once in a while… Or: A wish for the future: console.log()

Once in a while there is Max6 mentioned aleady. And once in a while people post what they are missing in Max/MSP.
And not just once i a while but right now I realize how great it would be to have a JavaScript object for debugging like the “console” object in Chrome and Firefox(Firebug).

Just typing console.log(anObjectorArray) and seing in the Max windows it’s content!!!!

#55453
Apr 27, 2011 at 3:31am

I halfheartedly second the desire. There are other javascript additions that I ‘give this up’ for.

#199553
Apr 27, 2011 at 6:26pm

You can use something like this if you like. You can even add these kinds of functions to a global js file put in the js-extensions folder.

var foo = new Object();
foo.one = "test";
foo.two = 74;
foo.three = [9,10,11];

foo.bar = new Object();
foo.bar.bozo = "i'm not a clown";

myobjectprinter(foo,"foo");

function myobjectprinter (obj, name)
{
    if (( typeof obj == "number") || (typeof obj == "string") ) {
        post( name +  " :" + obj + "n");
    } else {
        for(var k in obj){
           if (obj[k] && typeof obj[k] == "object")
            {
                    myobjectprinter(obj[k], name + "[" + k + "]");
            } else {
                    post(name + "[" + k + "] : " + obj[k] +"n")
            }
        }
    }
}

#199554
Apr 28, 2011 at 5:30pm

global js file in jsextensions? I apologize if this is somewhere else, but could you please explain what you mean? it sounds like i I could have a bit of code in jsextensions and call code in it. would I need to ‘include’ the jsextension somehow?

#199555
Apr 29, 2011 at 5:06pm

Check out the Cycling ’74/jsextensions folder. When you launch any JS object, all the files in this folder are loaded and added to the global context, so you can create new classes or functions that can be used anywhere. You don’t need to include it explicitly, it is included.

http://cycling74.com/forums/search.php?q=jsextensions

Have fun.

-Joshua

#199556
May 3, 2011 at 2:07pm

Yeah, I poked around and figured it out. the .mxo files are interesting. I felt like i found waldo when I saw LiveAPI. This folder is great for personal patches, and only slightly less great for patches I want to share.

Many thanks!

#199557
Jun 30, 2011 at 11:32am

One question about jsextensions: it seems that once the folder has been read, any changes to files therein do not take effect until Max is restarted.

Is there any way to cajole Max into re-reading the directory?

#199558

You must be logged in to reply to this topic.