Forums > Javascript

setting message obj arguments with object.message( )

November 16, 2013 | 11:05 am

Hello All,

I’m having a little bit of an odd problem with some js being used to dynamically create and set message boxes for routing of OSC data. I have no problems getting info into my message boxes however max is adding quotation marks to my messages thus nullifying the messages usability as an OSC encoder.

Here is some code:

// ...in with the new
		numinlets = a; // update our global number of inlets to the new value
		if(numinlets) theudpsend = this.patcher.newdefault(300, 300, "udpsend", "localhost" ,8369); // make the udpsend
		for(k=0;k<a;k++) // create the new ctlin and uslider objects, connect them to one another and to the funnel
		
		{	
			this.box.inlets = (k+1);
			controlmess[k] = this.patcher.newdefault(300+(k*50), 50, "message");
			controlmess[k].message("set" , "/" + (this.patcher.name).toString() + "/button/" + (arguments[k+1]).toString() + " $1");
			theinlets[k] = this.patcher.newdefault(300+(k*25), 25, "inlet");
			theinlets[k].message ("comment","Button " + (arguments[k+1]).toString());
			this.patcher.connect(theinlets[k], 0, controlmess[k], 0);
			this.patcher.connect(controlmess[k], 0, theudpsend, 0);
		}

you can see where i am setting the message boxes with "control mess[k].message("set" , "/" + (this.patcher.name)……"

Whats I’m expecting is a message box set to read: /thispatchername/button/argumentname $1

What I am getting is: "/thispatchername/button/argumentname $1"

Does anyone know why I’m getting these quotation marks added to my messages?

Thanks in advance!


November 16, 2013 | 11:13 am

Note: I also tried to use sprintf objects instead of message objects however I was unable to get a space into the argument for the object.

I wanted to get: /thispatchername/button/argumentname %s

I was only able to get: /thispatchername/button/argumentname%s

adding a space anywhere in the sprintf refused to populate the object with the argument on creation without an error and I simply got empty object boxes.


November 16, 2013 | 11:24 am

Hi . did you tried [fromsymbol] ?


November 16, 2013 | 12:19 pm

from symbol object works to strip the quotation marks off of the message however the initial message that is connected to the patchers inlets still has the quotation which render the $1 argument ineffective. Is there a way to set the message box with JS so that it receives a message as an argument rather than a symbol?


November 16, 2013 | 3:11 pm

Ok, so maybe this is a weird bug?

If I add the $1 to the message using append instead of the normal all in one string then I get rid of the annoying quotations.

controlmess[k].message(‘append’, ‘$1′);


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