debug function javascript

Feb 15, 2010 at 3:42am

debug function javascript

hi,
sorry if this is obvious, i searched dcs and forums but couldn’t find an answer.
i have a basic patcher below, basically turns on/off a debug variable in the js script. if the function is called setdebug, it works ok, but if the function is called debug, it doesn’t work at all. indeed, when i call a function named debug from another one (not i the script below) it says “debug is not defined”. i’m not a javascript expert but my search of the web didn’t indicate debug() was a reserved function or keyword.
can anyone help? cheers,,

//the patch

– Pasted Max Patch, click to expand. –

//the javascript (debugtest.js)

//inlets and outlets
inlets = 2;
outlets = 1;

var dbg=1;

//if renamed to debug() it stops working

function setdebug(a)
{
dbg=arguments[0];
if(a) {
post(“debug on n”)
} else {
post(“debug off n”)
}
}

#48347
Feb 16, 2010 at 3:20am

so today i can call debug from another function without error. but i couldn’t see the debug message in the js or jsui list of messages (as per the “reserved words” paragraph from: http://cycling74.com/docs/max5/vignettes/js/jsbasic.html). the only debug message reference i could find was from messages to dsp/max, but renaming the function to other max/dsp functions works (i.e. set/reset the debug flag in the js). i just don’t know what behavior I’m seeing here.

#173828
Feb 20, 2010 at 1:06am

so does this work for everyone? no-one cares? or have i discovered an “undocumented feature”?
it’s not a big deal, but not knowing is bugging me,,

#173829
Feb 20, 2010 at 1:11am

I get the same behaviour as you mentioned in your first post. Sending any “debug” message to the javascript causes no response from a debug() or anything() function. Possibly something undocumented to do with the built in max debugger?

lh

#173830
Feb 20, 2010 at 1:16am

i see. cheers,,

#173831

You must be logged in to reply to this topic.