
Storing arrays/objects in application variables
That's a major disappointment...
So, the workaround would be to convert JScript arrays to strings using the
join method before storing them in application variables, and then split
them when needed? Or would it be better to build a lot of application
variables, where each array item goes into one application variable? Or are
there even better chaching alternatives? Perhaps generating an include file
with the neccesary code to regenerate the data structure?
I must also mention that I have some very complex data structures that I
would like to chache. For example a tree data structure with arrays of
objects containinig arrays of objects containing arrays of ...
Comments on this, please?
Best regards
Tomas Eklund, Sweden
P.S. This is how I mean:
If I have a simple array of objects like:
aTest[1].header = '<h1>Hello application</h1>';
aTest[1].body = '<p>This is a test.</p>';
aTest[1].image = '/images/test.gif';
aTest[1].number = 5;
aText[2].header = '<h1>Will this work?</h1>';
... etc
I could either store them in one big application variable like this
// build a long joined string of the entire array
// must be splitted i two steps afterwards
// data must not contain the separator characters
var aTemp = new Array();
for ( i in aTest )
{
aTemp[i] = "";
for ( j in aTest[i] )
{
aTemp[i] += aTest[i][j] + "|";
}
aTemp[i] = aTemp[i].slice(0,-1);
}
Application("aTest") = aTemp.join("");
Or in several smalll application variables like this
// making many small application variables
// of course one must add a few metadata variables as well
// not doing that here
for ( i in aTest )
for ( j in aTest[i] )
Application('aTest['+i+'].'+j) = aTest[i][j];
Or I could skip application variables alltogether and generate an include
file vith JScript code that regenerates the data structure. Of course, this
would be a challenging task if not done at the same point as where the
original data structure is built. The generated include file would looke
something like this (using the simple example above):
<%
var aTest = new Array();
aTest[1].header = '<h1>Hello application</h1>';
aTest[1].body = '<p>This is a test.</p>';
aTest[1].image = '/images/test.gif';
aTest[1].number = 5;
aText[2].header = '<h1>Will this work?</h1>';
... etc
%>