debug function javascript

tdaeik's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

//the patch

//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")
}
}

tdaeik's icon

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: https://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.

tdaeik's icon

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

Luke Hall's icon

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

tdaeik's icon

i see. cheers,,