title: Reading in information into arrays
body: <p>Say that I have the following information stored in a file subsysteminformation.txt</p>
  
  <pre><code>#{
      "buildnames": {
          label: "buildnames",
          data: ["test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4",
                 "test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4",
                 "test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4",
                 "test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4",
                 "test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4",
                 "test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4",
                 "test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4",
                 "test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4","test2-a1", "test2-a2", "test2-a3",  "test2-a4/"
          ]
          }}; 
  
  
  #{
      subsystem: "CAS",
    date: {
          label: "CAS",
          data: [null]
      },        
      time: {
          label: "CAS",
          data: [null]
      },
     modules: {
          label: "CAS",
           data: [null]
      }, 
      cases: {
          label: "CAS",
           data: [null]
      }, 
      failed: {
          label: "CAS",
                     data: [[0, 239], [1, 249], [2, 237], [3, 192],[4, 234], [5, 288], [6, 234], [7, 195],[8, 245], [9, 181], [10, 294], [11, 195],[12, 249], [13, 235], [14, 262], [15, 155],
            [16, 245], [17, 121], [18, 372], [19, 195],[20, 255], [21, 231], [22, 332], [23, 195],[24, 225], [25, 271], [26, 272], [27, 195],[28, 255], [29, 131], [30, 332], [31, 165],
            [32, 245], [33, 201], [34, 132], [35, 195],[36, 245], [37, 211], [38, 232], [39, 195],[40, 245], [41, 231], [42, 262], [43, 195],[44, 245], [45, 261], [46, 252], [47, 155],
            [48, 245], [49, 161], [50, 172], [51, 195],[52, 245], [53, 241], [54, 212], [55, 195],[56, 245], [57, 211], [58, 232], [59, 195],[60, 245], [61, 201], [62, 232], [63, 155],
            [64, 245], [65, 231], [66, 232], [67, 195],[68, 245], [69, 211], [70, 232], [71, 195],[72, 245], [73, 231], [74, 232], [75, 195],[76, 245], [77, 231], [78, 232], [79, 145],
            [80, 245], [81, 231], [82, 232], [83, 195],[84, 245], [85, 231], [86, 232], [87, 195],[88, 245], [89, 171], [90, 132], [91, 195],[92, 245], [93, 231], [94, 232], [95, 135],
            [96, 245], [97, 181], [98, 302], [99, 195],[100, 245], [101, 214], [102, 252], [103, 195],[104, 255], [105, 261], [106, 262], [107, 195],[108, 205], [109, 311], [110, 232], [111, 135],
            [112, 245], [113, 231], [114, 242], [115, 195],[116, 245], [117, 231], [118, 232], [119, 195],[120, 245], [121, 211], [122, 223], [123, 195],[124, 235], [125, 231], [126, 312], [127, 135]
            ]
      }, 
      cover: {
          label: "CAS",
           data: [[0, 235], [1, 239], [2, 237], [3, 192],[4, 234], [5, 288], [6, 234], [7, 195],[8, 245], [9, 181], [10, 294], [11, 195],[12, 249], [13, 235], [14, 262], [15, 155],
            [16, 245], [17, 121], [18, 372], [19, 195],[20, 255], [21, 231], [22, 332], [23, 195],[24, 225], [25, 271], [26, 272], [27, 195],[28, 255], [29, 131], [30, 332], [31, 165],
            [32, 245], [33, 201], [34, 132], [35, 195],[36, 245], [37, 211], [38, 232], [39, 195],[40, 245], [41, 231], [42, 262], [43, 195],[44, 245], [45, 261], [46, 252], [47, 155],
            [48, 245], [49, 161], [50, 172], [51, 195],[52, 245], [53, 241], [54, 212], [55, 195],[56, 245], [57, 211], [58, 232], [59, 195],[60, 245], [61, 201], [62, 232], [63, 155],
            [64, 245], [65, 231], [66, 232], [67, 195],[68, 245], [69, 211], [70, 232], [71, 195],[72, 245], [73, 231], [74, 232], [75, 195],[76, 245], [77, 231], [78, 232], [79, 145],
            [80, 245], [81, 231], [82, 232], [83, 195],[84, 245], [85, 231], [86, 232], [87, 195],[88, 245], [89, 171], [90, 132], [91, 195],[92, 245], [93, 231], [94, 232], [95, 135],
            [96, 245], [97, 181], [98, 302], [99, 195],[100, 245], [101, 234], [102, 232], [103, 195],[104, 245], [105, 231], [106, 232], [107, 195],[108, 245], [109, 301], [110, 232], [111, 135],
            [112, 245], [113, 231], [114, 242], [115, 195],[116, 245], [117, 231], [118, 232], [119, 195],[120, 245], [121, 211], [122, 223], [123, 195],[124, 235], [125, 231], [126, 312], [127, 135]
            ]
      }};  
  </code></pre>
  
  <p>And the following script to read in the information.</p>
  
  <p>
      
      </p>
  
  <pre><code>var xmlhttp;
  function loadXMLDoc(url,cfunc){
      if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
        }
      else
        {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      xmlhttp.onreadystatechange=cfunc;
      xmlhttp.open("GET",url,true);
      xmlhttp.send();
  }
  
  
  function myFunction(){
      loadXMLDoc("subsysteminformation.txt",handleXML);
  }
  var checkState = function(xmlhttp, callback) {
    if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
      callback();
    } else {
      // Check back again 1 sec later
      setTimeout(checkState, 1000);
    }
  };
  
  
  function handleXML()
    {
  checkState(xmlhttp, function() {
     var txt=xmlhttp.responseText;
     var datasets = [];
     var datasetsCounter =0;
     var secondPos;
     var aPosition;
     var currentCharacterLocation;
  while(txt.indexOf("#") &gt; -1){   
      aPosition = txt.indexOf("#");
      secondPos = txt.indexOf("#", (aPosition)+1);
      aPosition++;
      datasets[datasetsCounter]=txt.substring(aPosition, secondPos);
      //var stringToCompare = txt.substring(aPosition, secondPos);
      txt = txt.substring(secondPos);
      datasetsCounter++;
      document.write("done");
  </code></pre>
  
  <p>}</p>
  
  <pre><code>});
    }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onLoad="myFunction()"&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now to my problem</p>
  
  <p>this section is terribly wrong</p>
  
  <p>while(txt.indexOf("#") > -1){<br>
          aPosition = txt.indexOf("#");
          secondPos = txt.indexOf("#", (aPosition)+1);
          aPosition++;
          datasets[datasetsCounter]=txt.substring(aPosition, secondPos);
          //var stringToCompare = txt.substring(aPosition, secondPos);
          txt = txt.substring(secondPos);
          datasetsCounter++;
          document.write("done");
  }</p>
  
  <p>What I want to do is to check if there are any more "#" characters in the text file, and if so read everything after (until the next "#" character or until there are no more characters at all in the document) into the array datasets[i], but I never get past the first #, perhaps some of you bright fellows out there could assist me in what I'm doing wrong, what shall I write instead of "if(txt.indexOf("#")" to check if there are any more "#" characters in the subsysteminformation.txt file?   </p>
  
  <p>Also how do I read in the last bit of information when there are no more "#" characters in the text?</p>
  
  <p>Thanks in advance =)</p>
  
  <p><strong>EDIT I'ts a plus if the sollution is fast since I will have approx 100 "#" characters in the file subsysteminformation.txt =)</strong></p>
  
  <p><strong>EDIT 2 The problem is that I never get out of the "While" loop, it just keeps on going and going, I just want that as soon as one "#" character has been used, just move on to the next, don't reuse the same "#" character again. =)</strong></p>