XML Feeds

.

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

vade doktorp at mac.com
Fri Dec 7 15:50:27 MST 2007


so just a heads up - it works 100% SOme psuedocode below that illustrates if you want to handle multiple pattr entries in pattr:


// the variables I want to store
var somefloat = 3.14159;
var somestuff = "some stuff or whatever";
var someint = 10;

//make an array of items you want to store
var mypattritems = new Array()

function updatePattr()
{
  mypattritems[0] = somefloat;
  mypattritems[1] = somestuff;
  mypattritems[2] = someint;
  notifyclients(); // for pattr to notice!
}

// for pattrstorage to store it 
function getvalueof()
{
  return mypattritems; // this sends the array to pattrland
}

// for pattrstorage to return it to JS
function setvalueof()
{
   // note we use ARGUMENTs here, not like in the manual 

   pi = arguments[0];
   stuff = arguments[1];
   someint = arguments[2];
}

// getter setter methods for our individual variables
msg_int(v)
{
  someint = v;
 updatePattr(); // updates our array with the new values and tells pattr
}

function msg_float(v)
{
  somefloat = v;
  updatePattr();
}

etc. etc.


Thanks again -ej!


More information about the javascript-dev mailing list