< Back to IRCAM Forum

Sending message via javascript with Max

Hi,
I’m pretty new to Max and to spat. I have a max js object, and I’m trying to send panning information to a spat object. My javascript object outlet 0 is connected to input 0 of the spat object and I have the following (very reduced fragment of code):
var to_snd = “/source/0/xyz 1 2 6”;
outlet(0,to_snd);
I get the error message
spat5.pan~: OSC format error: Character " " not allowed in address pattern “/source/0/xyz 1 2 6”

Any idea what I’m doing wrong? I’m running the latest version of spat.

Regards

Justin

To answer my own question. You have to use arrayfromargs you need code something like
var message_name = “/source/”+spat_port+"/xyz";
var to_snd = arrayfromargs(message_name,current_line);
outlet(0,to_snd);

Where current_line is an array containing the three coordinates.

Hi Justin,

Thanks for the info.
Indeed, messages have to be properly typed.
(could you send your faulty JS example ? I will try to detect the formatting issue and provide a more meaningful error message, if possible)

Regards,
T.

Packing things up with arrayfromargs is the solution. I think it was just me misunderstanding how you send messages to objects in javascript. In my first post I sent a pure string that seemed to confuse spat. I’m not sure how you would improve the error message, since you don’t really know that the message is coming from a js object.