Look Up Table Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Harshpandya
    New Member
    • Jun 2007
    • 30

    Look Up Table Help

    Here is my code for look up table - where i am planning to built 10 colums and 8 rows and put [x,y] array values in the table boxes. Problem is - it is only printing the last array valules instead of all

    [CODE=javascript] var maxRow = 10;
    var maxCol = 8;
    var height1 = 480;
    var width1 = 640;

    function CenteringError( Xe, Ye){

    var table = new Array ( ([5,0], [2,-3], [2,-3], [1,-2], [0,-2], [0,-1], [1,-1], [1,-1], [0,-1], [-5,2]),
    ([3,-2], [-1,-3], [-1,-3], [1,-2], [-1,-2], [1,-1], [1,-1], [2,-2], [2,-2], [-3,-1]),
    ([1,-3], [-2,-3], [-2,-3], [-2,-2], [-1,-2], [0,0], [1,-1], [2,-1], [2,-1], [1,-2]),
    ([-2,0], [-2,-1], [-2,-1], [-2,0], [-1,0], [1,0], [2,0], [2,0], [2,0], [2,0]),
    ([-2,-1], [-2,-1], [-2,-1], [-2,0], [-1,0], [1,0], [3,0], [2,1], [2,1], [2,0]),
    ([-1,1], [-2,0], [-2,0], [-2,1], [-1,1], [1,1], [2,1], [2,1], [2,2], [1,2]),
    ([-1,2], [-2,1], [-2,1], [-2,1], [-1,2], [-1,1], [1,1], [1,3], [1,2], [-2,3]),
    ([4,1], [0,0], [-1,0], [-1,0], [-1,0], [0,2], [0,1], [-1,2], [-1,3], [-4,2])
    );
    var correct = [0,0];

    //this math function gets mouse pos and builts Rows and Colums in Viewer

    correct[0] = table[Math.round((max Row* Ye)/height1)];
    correct[1] = table[Math.round((max Col* Xe)/width1)];

    var x = correct[0];
    var y = correct[1];

    alert(x + " " + y);
    }
    [/CODE]

    I am alerting x and y values but it only prints certain numbers and repeats it. This program is not working properly. I dont know why.

    Help would be appreciated...

    Thanks
    Last edited by acoder; May 15 '08, 09:05 AM. Reason: Added code tags
  • rnd me
    Recognized Expert Contributor
    • Jun 2007
    • 427

    #2
    change your parens to array brackets and try again.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Harshpandya, please enclose your posted code in [code] tags (See How to Ask a Question).

      This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

      Please use [code] tags in future. Thanks!

      Comment

      Working...