js: js: no function gettype [.js]

ricky's icon

Getting a weird error even though the script works as expected:

js: js: no function gettype [scriptname.js]

Any ideas?

ricky's icon

link to code: http://codepad.org/5qFF1I89

ricky's icon

anyone any ideas?

DK's icon

You don't have a gettype() function defined anywhere in the JS...is your patch sending a gettype message somewhere?

ricky's icon

Entire script is as follows:

inlets = 1;
outlets = 1;

var x = 0;

Math.log2 = Math.log2 || function(x){return Math.log(x)*Math.LOG2E;};

function msg_float(v) 
{        
     x = (v > 0 ? ((Math.log2(v) - Math.log2(10)) / (Math.log2(2000) - Math.log2(10))) : 0);    
     outlet(0, x);
}
ricky's icon

I should note this is a script in a Max for Live device and it works exactly as expected.

DK's icon

JS throws that error when it is sent a message for which there is no corresponding function defined. Something in your device is sending a message "gettype" to your js object, and your script has no gettype() function.

ricky's icon

Of course that makes sense but it isn't the case. I resolved this issue by replacing the polyfill:

inlets = 1;
outlets = 1;
function log2(x){ return Math.log(x)*Math.LOG2E;}
function msg_float(v) 
{        
    var x = 0;
    x = (v > 0 ? ((log2(v) - log2(10)) / (log2(2000) - log2(10))) : 0);    
    outlet(0, x);
}