XML Feeds

.

[javascript-dev] Re: javascript + Pattr question - storing multiple values of mixed types (string/float)

Emmanuel Jourdan c74-mailinglists at e--j.com
Fri Dec 7 10:59:57 MST 2007


On 7 déc. 07, at 18:31, vade wrote:

> Yeah, totally, I was initially quite confused by the functions, as I  
> did not see how to do exactly that, and then noticed the mention of  
> arrays, and deduced one had to manage this oneself.

Your code have some issue. You should call notifyclients() when your  
pattr state change. It doesn't make sense to recall it (trough your  
pattrUpdate() function) inside getvalueof(). I didn't test it:

var currentPattr = new Array();
var mode...

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;
}
pattrUpdate.private = 1;

function getvalueof()
{
	post("storing pattr state");
	post();
	pattrUpdate();		// update the states
	return currentPattr;	// our aggregate array of pattr variables
}

function setvalueof(v)
{
	post("recalling pattr state");
	post();
	
	// set our values
	mode = v[0];
	minval = v[1];
	maxval = v[2];
	currentval = v[3];
	currenttitle = v[4];
	listsize = v[5];
	listmode = v[6];
//	menuitems = v[7];
	
	resize();
	debug();
}

// debug
function debug()
{
	post("mode = " + mode);
	post();
	post("min = " + minval);
	post(" max = " + maxval);
	post();
}

// just to test:
function setmode(s)
{
	mode = s;		// store your new mode

	notifyclients();	// update the pattr values
}

Best,
ej





More information about the javascript-dev mailing list