Sending messages to an inlet of an object using javascript

Cphas's icon

Hi I'm struggling with a patch I'm writing. It generates a load of elements and I need to send a list to an inlet object in order to initialise everything. the message() function looks like it should work but I keep getting messages saying that inlet does not understand the message. Can anyone point out what I'm dong wrong? This is the code I am using:

pan[i].subpatcher().getnamed("inlet").message("id "+a[(2*i)+2]);

Many thanks in advance

KrisW's icon

Hi
if your message stands for list then u need to separate these guys with comma eg : message("id",1,2,3,4) ;

Cphas's icon

Hi Krisw I've tried that as well, the code I posted was after a few desperate changes. I still get exactly the same message. I could rewrite it using a spray but it would just be so much more elegant to be able to send the message directly from javascipt.

KrisW's icon

perhaps that INLET wont pass that message through , im not sure (i cant check it now ) but inlet may think that you dedicated this message only for him . but i might be wrong . . . experiment with receive (give it a JS name) send to it your message , if it doesnt work try without "id" but prepend it after the receive object . sorry i cant check it now

Cphas's icon

Ok thanks for your help. I have a feeling that there must be some kind of prefix that needs to be there so Max knows the message is for the actual object and not the object box but I can't find what it might be.

KrisW's icon

let me know if you will find out , im interested

pdelges's icon

The inlet object has indeed no input (it is an input) and doesn't understand any message.
You may want to send your message to the object(s) connected to inlet's output. Or connect js' output to the input of the subpatch...

Cphas's icon

You are completely correct that is a mistake on my part. Basically what i was trying to do was send a message to the inlet of a bpatcher and in my frustration switched to trying send it to the inlet itself. But i was having exactly the same problem in that it said it didn't understand the message. I'll have another try.

KrisW's icon

patrick has good suggestion to connect JS directly to bpatcher .
also u can send list's to a RECEIVE (with scripting name) then prepend that list with "id" into bpatcher . i just tried that

Cphas's icon

Yeah that's what I've ended up doing ti was just a bit ugly as there are several objects that need to be connected and I need to use a spray etc. I just thought it would be an easy solution but anyway thanks for the help guys :)