Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is with the initialization of your <code>abswidth</code>. You've done this</p> <pre><code>var absw1dth = [[]]; </code></pre> <p>...which will create an array with one element, another array with no elements. So when <code>e</code> is <code>1</code> (rather than <code>0</code>), the expression <code>absw1dth[e][0]</code> is trying to index into an array <code>abswidth[1]</code> that doesn't exist.</p> <p>If the data is as static as you've shown (there will always only be four rows in the <code>r0w</code> array), you could solve it with initialization:</p> <pre><code>var absw1dth = [ [], [], [], [] ]; </code></pre> <p>Now <code>abswidth</code> is a four-element array, where each element is an empty array.</p> <p>But if the data is more dynamic, I'd probably initialize on-the-fly:</p> <pre><code>var absw1dth = []; // Just an empty array for (e=0 ; e &lt; r0w.length ; e++ ) { abswidth[e] = []; // Create this element absw1dth[e][0] = ( r0w[e][7] + r0w[e][1] ); for (f=8 ; f &lt; r0w[e].length ; f++ ) { absw1dth[e][f - 7] = (r0w[e][f] + absw1dth[e][f - 8]); }; }; // ... } </code></pre> <p>If it's possible that code you're not showing may have already created the array elements within <code>abwidth</code>, but also may not have, you can test first:</p> <pre><code>var absw1dth = []; // Just an empty array for (e=0 ; e &lt; r0w.length ; e++ ) { if (!abswidth[e]) { abswidth[e] = []; // Create this element } absw1dth[e][0] = ( r0w[e][7] + r0w[e][1] ); for (f=8 ; f &lt; r0w[e].length ; f++ ) { absw1dth[e][f - 7] = (r0w[e][f] + absw1dth[e][f - 8]); }; }; // ... } </code></pre> <p>Or go all "functional programming" and use JavaScript's <a href="http://blog.niftysnippets.org/2008/02/javascripts-curiously-powerful-or.html" rel="nofollow">curiously-powerful <code>||</code> operator</a>:</p> <pre><code>var absw1dth = []; // Just an empty array for (e=0 ; e &lt; r0w.length ; e++ ) { abswidth[e] = abswidth[e] || []; // Create this element if needed absw1dth[e][0] = ( r0w[e][7] + r0w[e][1] ); for (f=8 ; f &lt; r0w[e].length ; f++ ) { absw1dth[e][f - 7] = (r0w[e][f] + absw1dth[e][f - 8]); }; }; // ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload