Forums > MaxMSP

object "script name" in javascripting

March 10, 2009 | 7:06 am

hello all,
I’m trying to access an object in a patch from javascript .
Object was not created by the script , the object have got a "script name" that can be easily adresed with a "script …." message sent to a "thispatch" object.
What is the syntax within javascrip to adress the named object directly ?
I know I can outlet a message connected directely to the "thispatch" object but what I’m looking for is a wireless method .

The second level of my question is how to adress objects that are within a subpatch or bpatch ….

Thanks

zoomak


March 10, 2009 | 8:10 am

This question should probably be in the dedicated javascript forum but no matter. To get the maxobj of a named object and then send it a message you should try this. You might want to have a look through the javascript tutorials in the max help section too, they’re quite useful.

lh

// getnamed.js
function dostuff (x,y)
{
var obj = this.patcher.getnamed(x);
obj.message(y);
}
// EOF

– Pasted Max Patch, click to expand. –

March 10, 2009 | 11:40 pm

thank you lh,
the "getnamed" was the missing key for me .
sorry for posting in the bad forum .
I had a look a the right forum for javascripting and I have read many interresting stuffs Wink
thanks again.

zoomak


March 11, 2009 | 2:23 am

Just an extra pointer: for non UI objects you might need to change this to:

obj.message("sendbox",somemessage);

If you open the object inspector you can drag an attribute on to your main patch and it will create a message box with the message format already in place, this will make it easy to figure out what you need to send in your js message.

lh


March 11, 2009 | 10:53 pm

thank you so much lh, very helpful hint .


March 12, 2009 | 3:45 am

just want to add, if you don’t need the messages instantiated into your patch(i.e. you just need to know what they are in order to enter into your js code), you could simply open up the inspector, click the "@" symbol at the bottom left of the inspector and this will open up the entire list of attribute names for every available attribute right there in the inspector(although maybe you still want to drag since the instantiated messages will also show whether you need one or more arguments to the message).


March 13, 2009 | 6:52 pm

thank you RabidRaja,
may be I can ask another question please ….
I posted a new topic about accessing objects within a bpatcher in the javascrpit forum (I don’t know how to insert here the link to that topic, sorry)
Can you have a look at it please.
Thanks in advance .

zoomak


Viewing 7 posts - 1 through 7 (of 7 total)