Danne
10-16-2002, 08:55 PM
Hi!
I have a bunch of values that I'd like to store on clientside. I pass these using a big string (8kb), and then I break it in a recursive function and store it in a multidimensional array.
I have tested this function on Serverside, using ASP and JScript, and it works. But on clientside I get a stack overflow.
The structure of the string is as follows:
"[value,value,[value,value,value,value]]]"
The function that breaks this string, looks like this:
Help would be much appreciated.
function toArray(pString)
{
var i;
var arr = new Array();
var ct = 0;
var tempNode = "";
for (i=0; i < pString.length; i++)
{
if (pString.charAt(i) == "[") // Start a new level
{
pString = pString.slice(0, i+1) + pString.slice(pString.length-1);
arr[ct] = toArray(pString );
} else if (pString.charAt(i) == "]") // Next node
{
arr[ct] = tempNode;
tempNode = "";
ct++;
} else { // Assign value
tempNode += pString.charAt(i);
}
}
return arr;
}
I have a bunch of values that I'd like to store on clientside. I pass these using a big string (8kb), and then I break it in a recursive function and store it in a multidimensional array.
I have tested this function on Serverside, using ASP and JScript, and it works. But on clientside I get a stack overflow.
The structure of the string is as follows:
"[value,value,[value,value,value,value]]]"
The function that breaks this string, looks like this:
Help would be much appreciated.
function toArray(pString)
{
var i;
var arr = new Array();
var ct = 0;
var tempNode = "";
for (i=0; i < pString.length; i++)
{
if (pString.charAt(i) == "[") // Start a new level
{
pString = pString.slice(0, i+1) + pString.slice(pString.length-1);
arr[ct] = toArray(pString );
} else if (pString.charAt(i) == "]") // Next node
{
arr[ct] = tempNode;
tempNode = "";
ct++;
} else { // Assign value
tempNode += pString.charAt(i);
}
}
return arr;
}