Hi all,

the following example function generates a complex data structure 
(Hash->Hash->Array):

----- Example ------------
function localTest() {
   testHash = {};
   var hashKeys = ["key1","key2"];
   var value = 0;
   for (var currentKey in hashKeys) {
     value++;
     if (testHash[currentKey].type != "hash") {
       testHash[currentKey] = {};
     }
     if (testHash[currentKey]..secondLevel.type != "array") {
       testHash[currentKey]..secondLevel = [];
     }
     testHash[currentKey]..secondLevel.push(value);
   }
   print testHash;
}
localTest;

----- Example Output 1 -----
{
   key1  :
   {
     secondLevel  :
     [
       1
     ]
    }
   key2  :
   {
     secondLevel  :
     [
       2
     ]
    }
  }
--------------------------

The hash 'testHash' is global here. It should better be local. But by 
using "var testHash = {}" the data structure isn't build correctly any more:

----- Example Output 2 -----
2

--------------------------

While building this minimal example I noticed that it seems to be 
specific for an array as third level. With a hash there it works as 
expected.
And changing the notation ('.[]' instead of '..') also solves the 
problem, e.g:

  testHash[currentKey].["secondLevel"] = [];

Regards,
Rolf
-- 

Rolf Huehne
Postdoc

Leibniz Institute for Age Research - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany

Phone:   +49 3641 65 6205
Fax:     +49 3641 65 6210
E-Mail:  rhue...@fli-leibniz.de
Website: http://www.fli-leibniz.de

           Scientific Director: Prof. Dr. K. Lenhard Rudolph
        Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Dennys Klein

VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to