title: How to build an array from list and cfquery?
body: <p>I'm trying to build an array that will give me all values from my list and then based on the records from the cfquery I wan to get values for years. To make this more clear I will show you below how my array should look like:</p>
  
  <pre><code>time slot   year2015   year 2016
  0700            0          0
  0715            1          0
  0730            0          0
  0745            0          0
  0800            0          5
  </code></pre>
  
  <p>and so on. My time slot values are stored in <code>&lt;cfset dataList&gt;</code> and that looks like this:</p>
  
  <pre><code>&lt;cfloop list="#ListGetAt(dataList,i,",")#" index="k" delimiters="|"&gt;
          &lt;cfoutput&gt;#k#&lt;/cfoutput&gt;
      &lt;/cfloop&gt;
  
  0600 0615 0630 0645 0700 0715 0730 0745 0800 0815 0830 0845 0900 0915 0930 0945 1000 1015 1030 1045 1100 1115 1130 1145 1200 1215 1230 1245 1300 1315 1330 1345 1400 1415 1430 1445 1500 1515 1530 1545 1600 1615 1630 1645 1700 1800 1900 2000 2100 2200 2300 0000 
  </code></pre>
  
  <p>My time slot, years and values for each year are outputted from cfquery that looks like this:</p>
  
  <pre><code>&lt;cfoutput query="getRecords" group="YearRecord"&gt;
      &lt;cfoutput&gt;
          #TimeSlot# - #YearRecord# - #ValueYear#&lt;br/&gt;
      &lt;/cfoutput&gt; 
  &lt;/cfoutput&gt;
  
  0830 - 2015 - 2
  0915 - 2015 - 2
  1000 - 2015 - 1
  0630 - 2016 - 1
  0800 - 2016 - 1
  </code></pre>
  
  <p>My records are coming from two different locations. Time slots from my list and records with valid values from my cfquery. So I want to build my array that contains all records from my list and for each record I want to output year column with the valid value. So I tried first to populate my array with the elements from the list:</p>
  
  <pre><code>&lt;cfset myArray=ArrayNew(1)&gt;
  
  &lt;cfloop list="#ListGetAt(dataList,i,",")#" index="z" delimiters="|"&gt;
      &lt;cfoutput&gt;
          #myArray[z]#
      &lt;/cfoutput&gt;
  &lt;/cfloop&gt;
  </code></pre>
  
  <p>and this code give me an error:</p>
  
  <pre><code>Type: Expression ********** Line: 253 ********** ********** The element at position 600 of dimension 1, of array variable &amp;quot;MYARRAY,&amp;quot; cannot be found.
  </code></pre>
  
  <p>Also after I populate array I would have to add two more elements to that array. Year and values for each year. If anyone knows what I'm doing wrong and what is the best way to do this please let me know. Thanks in advance. </p>