js with set function and using javascript to set value...

Peter Nyboer's icon

I'm using this javascript to set values of various max objects:

function anything(){
post("nexample",messagename,arguments[0]);
var knob = this.patcher.getnamed(messagename);
knob.set(arguments[0]);
}

if I try to "set" the value of a jsui this way, I get the error:

• error: js: junk.js: Javascript TypeError: knob.set is not a function, line 4
• error: js: error calling function jsknob

But the jsui does have a "set" function in it!
This happens in Max 4x and Max 5.

Here's a patch that illustrates this, call the above javascript "junk.js":

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

Joshua Kit Clayton's icon

For JSUI or other objects which have methods hidden inside via the
"anything" method. Use the message() synax

o.message("set", whatever);

-Joshua

Peter Nyboer's icon

ah, right. thanks for the clue!

P