[javascript-dev] javascript + Pattr question - storing multiple values of mixed types (string/float)
vade
doktorp at mac.com
Fri Dec 7 09:59:00 MST 2007
- Previous message: [javascript-dev] Re: Callback for bpatcher resize event?
- Next message: [javascript-dev] Re: javascript + Pattr question - storing multiple values of mixed types (string/float)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello
So i am in the process of pattrfying one of my javascripts. I have implemented setvalueof and getvalueof, and within my patch my pattrstorage instance properly sees multiple variables.
My data within the client window is such:
"float 0 1 0 Var1 10 0"
(gui mode, minval, maxval, currentvalue, currenttitle, listsize, listtype for those interested).
Now, those variables are global to my JS, and I am attempting to store them within an array - which seems to work at least for SETTING, however recalling does some weird things:
(I am setting an array called currentPattr to hold my 'multiple' values - I call pattrUpdate rather than notifyclients within my code to update this currentPattr array, which then calls notifyclients itself)
[code]
// pattr compatibility
function pattrUpdate()
{
// set our array to current global state - have to use an array for pattr since we can only get/set one variable.
currentPattr[0] = mode;
currentPattr[1] = minval;
currentPattr[2] = maxval;
currentPattr[3] = currentval;
currentPattr[4] = currenttitle;
currentPattr[5] = listsize;
currentPattr[6] = listmode;
// currentPattr[7] = menuitems;
// post(currentPattr);
// do our actual pattr updates
notifyclients();
}
function getvalueof()
{
post("storing pattr state");
post();
return currentPattr; // our aggregate array of pattr variables
pattrUpdate();
}
function setvalueof(v)
{
post("recalling pattr state");
post();
currentPattr = v;
// set our values
mode = currentPattr[0];
minval = currentPattr[1];
maxval = currentPattr[2];
currentval = currentPattr[3];
currenttitle = currentPattr[4];
listsize = currentPattr[5];
listmode = currentPattr[6];
// menuitems = currentPattr[7];
pattrUpdate();
resize();
debug();
}
// debug
function debug()
{
post("mode = " + mode);
post();
post("min = " + minval);
post(" max = " + maxval);
post();
}
[/code]
as far as I can tell, setting works (as far as I understand, using getvalueof results in proper values in my pattrstorage window (otherwise, why would I see the full values I see?)),
using my setvalueof to restore client state results in debug printing for example
recalling pattr state
mode = f
min = l max = o
storing pattr state
digging further I've iterated over my recalled currentPattr from getvalueof() and note it does not contain all the data I had expected
So, how do I properly pack in the values of mixed string/floats to pattr and recall them?
Do I need to use multidimensional arrays or something?
Forgive me if this is obvious, I feel like I am overlooking something staring me in the face.
Thanks again!
- Previous message: [javascript-dev] Re: Callback for bpatcher resize event?
- Next message: [javascript-dev] Re: javascript + Pattr question - storing multiple values of mixed types (string/float)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
