I’m getting the object like this
a = this.patcher.getnamed("amp_env_function");
Then sending the message like this
a.message("sustain 3 0");
I’m also sending a list of x+y coordinates, correctly formatted with commas, as far as I know.
I get this message – "function: doesn’t understand "sustain 3 0""
Now if I do a bit of symbol fiddling in the Max environment I can get it to update the function object with the right values, but why can’t I do this directly from JS?
a.message("sustain", 3, 0);
This will send the symbol sustain with 2 arguments.
Thanks EJ, does that mean all objects I’m sending lists to should be formatted in this way?
Yes or you can pass an array which will be unrolled automatically.
var tmp = new Array(); tmp = "sustain"; tmp = 3; tmp = 0; a.message(tmp);
You can also use the literal notation.
I’ve another question which might come under this topic.
However when sending the same message to Pattrstorage using setstoredvalue, I seem to be setting things that I shouldn’t be.
The first four items in the array seem to start with the length(domain) of the Function object, two of the others might be the Lo and Hi Display Range. Also, Am I right in thinking that the array changes for a sustain point too? Does this make any sense?
Is there any documentation on how the Pattr system stores lists related to UI objects?
OK so it appears that,
 = domain length
 = lo range
 = hi range
Then what follows are the points of the function, and after each point a ’0′ or ’2′. Zero indicates no sustain, while 2 means sustain is on.
So an array with the following, creates an ADSR, with 270 being the length, and the range being from 0 – 1.
270, 0, 1, 0, 0, 0 , 15.97, 1, 0, 71.42, 0.62, 0, 179.38, 0.57, 2, 269.99, 0, 0
270(length), 0(lo), 1(hi), 0, 0, 0(point1), 15.97, 1, 0(point2), 71.42, 0.62, 0(point3), 179.38, 0.57, 2(point4 w sustain), 269.99, 0, 0(point5)
Please correct me if I’m wrong, but that’s working OK for me now.