Forums > Javascript

Sending messages to an inlet of an object using javascript

June 28, 2013 | 5:55 am

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

June 28, 2013 | 6:19 am

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

June 28, 2013 | 6:25 am

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.

June 28, 2013 | 6:30 am

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

June 28, 2013 | 6:32 am

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.

June 28, 2013 | 6:34 am

let me know if you will find out , im interested

June 28, 2013 | 8:39 am

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…

June 28, 2013 | 8:43 am

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.

June 28, 2013 | 8:47 am

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

June 28, 2013 | 9:11 am

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 :)

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

Forums > Javascript